Skip to content

Commit

Permalink
update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
pavjacko committed Mar 4, 2024
1 parent 8605145 commit 73bf6f6
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 98 deletions.
45 changes: 23 additions & 22 deletions packages/cli/src/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,42 @@ export const logInitialize = () => {
export const logWelcome = () => {
const ctx = getContext();
const chalCol = currentChalk.rgb(10, 116, 230);

const shortLen = 64;
// prettier-ignore
let str = _defaultColor(`
┌──────────────────────────────────────────────────────────────────────────────
${chalCol('██████╗')} ███████╗${chalCol('███╗ ██╗')} █████╗ ████████╗██╗${chalCol('██╗ ██╗')}███████╗
${chalCol('██╔══██╗')}██╔════╝${chalCol('████╗ ██║')}██╔══██╗╚══██╔══╝██║${chalCol('██║ ██║')}██╔════╝
${chalCol('██████╔╝')}█████╗ ${chalCol('██╔██╗ ██║')}███████║ ██║ ██║${chalCol('██║ ██║')}█████╗
${chalCol('██╔══██╗')}██╔══╝ ${chalCol('██║╚██╗██║')}██╔══██║ ██║ ██║${chalCol('╚██╗ ██╔╝')}██╔══╝
${chalCol('██║ ██║')}███████╗${chalCol('██║ ╚████║')}██║ ██║ ██║ ██║${chalCol(' ╚████╔╝ ')}███████╗
${chalCol('╚═╝ ╚═╝')}╚══════╝${chalCol('╚═╝ ╚═══╝')}╚═╝ ╚═╝ ╚═╝ ╚═╝${chalCol(' ╚═══╝ ')}╚══════╝
┌─────────────────────────────────────────────────────────────────┐
${chalCol('██████╗')} ███████╗${chalCol('███╗ ██╗')} █████╗ ████████╗██╗${chalCol('██╗ ██╗')}███████╗ │
${chalCol('██╔══██╗')}██╔════╝${chalCol('████╗ ██║')}██╔══██╗╚══██╔══╝██║${chalCol('██║ ██║')}██╔════╝ │
${chalCol('██████╔╝')}█████╗ ${chalCol('██╔██╗ ██║')}███████║ ██║ ██║${chalCol('██║ ██║')}█████╗ │
${chalCol('██╔══██╗')}██╔══╝ ${chalCol('██║╚██╗██║')}██╔══██║ ██║ ██║${chalCol('╚██╗ ██╔╝')}██╔══╝ │
${chalCol('██║ ██║')}███████╗${chalCol('██║ ╚████║')}██║ ██║ ██║ ██║${chalCol(' ╚████╔╝ ')}███████╗ │
${chalCol('╚═╝ ╚═╝')}╚══════╝${chalCol('╚═╝ ╚═══╝')}╚═╝ ╚═╝ ╚═╝ ╚═╝${chalCol(' ╚═══╝ ')}╚══════╝ │
`);

if (ctx.files?.rnv?.package?.version) {
ctx.rnvVersion = ctx.files.rnv.package.version;
str += printIntoBox(
` Version: ${currentChalk.green(ctx.rnvVersion)} ${ICN_ROCKET} ${currentChalk.yellow('Firing up!...')}`
`Version: ${currentChalk.green(ctx.rnvVersion)} ${ICN_ROCKET} ${currentChalk.yellow('Firing up!...')}`,
shortLen
);
if (ctx.rnvVersion?.includes?.('alpha')) {
str += printIntoBox(` ${currentChalk.yellow('WARNING: this is a prerelease version.')}`);
str += printIntoBox(`${currentChalk.yellow('WARNING: this is a prerelease version.')}`, shortLen);
}
}
str += printIntoBox(
` ${currentChalk.grey('https://renative.org')} | Start Time: ${currentChalk.grey(
`${currentChalk.grey('https://renative.org')} | Start Time: ${currentChalk.grey(
ctx.timeStart.toLocaleString()
)}`
)}`,
shortLen
);
// str += printIntoBox(` ${ICN_ROCKET} ${currentChalk.yellow('Firing up!...')}`);
str += printIntoBox(` $ ${currentChalk.cyan(getCurrentCommand(true))}`);
str += printIntoBox(`$ ${currentChalk.cyan(getCurrentCommand(true))}`, shortLen);
if (ctx.timeStart) {
// str += printIntoBox(` Start Time: ${currentChalk.grey(ctx.timeStart.toLocaleString())}`);
}
// str += printIntoBox('');
str += printBoxEnd();
// str += printBoxEnd();
str += _defaultColor('└─────────────────────────────────────────────────────────────────┘');
// str += '\n';

console.log(str);
Expand Down Expand Up @@ -281,7 +284,7 @@ export const logSummary = (header = 'SUMMARY') => {

str += logContent.replace(/\n\s*\n\s*\n/g, '\n\n');

str += printIntoBox('');
// str += printIntoBox('');
if (ctx.runtime?.platformBuildsProjectPath) {
str += printIntoBox('Project location:');
str += printIntoBox(`${currentChalk.cyan(_sanitizePaths(ctx.runtime.platformBuildsProjectPath || ''))}`);
Expand Down Expand Up @@ -561,12 +564,11 @@ export const logAppInfo = (c: RnvContext) => {
}
};

export const printIntoBox = (str: string) => {
let output = _defaultColor('│ ');
export const printIntoBox = (str: string, maxLen = 64) => {
let output = _defaultColor('│ ');

const strLenDiff = str.length - stripAnsi(str).length;
output += _defaultColor(str);
const maxLen = 76;
const len = maxLen - (str.length - strLenDiff);
if (len > 0) {
for (let i = 0; i < len; i++) {
Expand Down Expand Up @@ -611,15 +613,14 @@ export const printArrIntoBox = (arr: Array<string>, prefix = '') => {
};

export const printBoxStart = (str: string, str2?: string) => {
let output = _defaultColor('┌──────────────────────────────────────────────────────────────────────────────┐\n');
let output = _defaultColor('┌─────────────────────────────────────────────────────────────────┐\n');
output += printIntoBox(str);
output += printIntoBox(str2 || '');
output += _defaultColor('├──────────────────────────────────────────────────────────────────────────────┤\n');
output += _defaultColor('├─────────────────────────────────────────────────────────────────┤\n');
return output;
};

export const printBoxEnd = () =>
_defaultColor('└──────────────────────────────────────────────────────────────────────────────┘');
export const printBoxEnd = () => _defaultColor('└─────────────────────────────────────────────────────────────────┘');

const Logger: RnvApiLogger = {
logHook,
Expand Down
28 changes: 13 additions & 15 deletions packages/core/jsonSchema/rnv.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@
"enum": [
"ios",
"android",
"firetv",
"androidtv",
"androidwear",
"firetv",
"web",
"webtv",
"tizen",
Expand Down Expand Up @@ -1255,7 +1255,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of URLs that will be injected on top of the Podfile as sources"
},
"podDependencies": {
"type": "array",
Expand All @@ -1273,7 +1274,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of strings that will be injected on top of the Podfile"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1471,10 +1473,17 @@
"items": {
"$ref": "#/definitions/rnv.app/properties/platforms/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
},
"didReceiveNotificationResponse": {
"type": "array",
"items": {
"$ref": "#/definitions/rnv.app/properties/platforms/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
}
},
"required": [
"willPresent"
"willPresent",
"didReceiveNotificationResponse"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -3349,11 +3358,6 @@
"android": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": true,
"description": "Marks plugin platform enabled or disabled"
},
"disabled": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -3451,9 +3455,6 @@
"ios": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.app/properties/plugins/additionalProperties/anyOf/0/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.app/properties/plugins/additionalProperties/anyOf/0/properties/android/properties/disabled"
},
Expand Down Expand Up @@ -3531,9 +3532,6 @@
"tizen": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.app/properties/plugins/additionalProperties/anyOf/0/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.app/properties/plugins/additionalProperties/anyOf/0/properties/android/properties/disabled"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/jsonSchema/rnv.engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
"enum": [
"ios",
"android",
"firetv",
"androidtv",
"androidwear",
"firetv",
"web",
"webtv",
"tizen",
Expand Down
9 changes: 5 additions & 4 deletions packages/core/jsonSchema/rnv.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"enum": [
"ios",
"android",
"firetv",
"androidtv",
"androidwear",
"firetv",
"web",
"webtv",
"tizen",
Expand Down Expand Up @@ -63,6 +63,10 @@
"additionalProperties": false
}
},
"disableTelemetry": {
"type": "boolean",
"description": "Opt-out from renative telemetry program. More info at https://renative.org/telemetry"
},
"appConfigsPath": {
"type": "string",
"description": "Enables you to define custom global appConfigs location that every project will automatically use"
Expand All @@ -72,9 +76,6 @@
"description": "schema definition"
}
},
"required": [
"projectTemplates"
],
"additionalProperties": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/jsonSchema/rnv.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"enum": [
"ios",
"android",
"firetv",
"androidtv",
"androidwear",
"firetv",
"web",
"webtv",
"tizen",
Expand Down
26 changes: 12 additions & 14 deletions packages/core/jsonSchema/rnv.plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@
"android": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": true,
"description": "Marks plugin platform enabled or disabled"
},
"disabled": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -467,9 +462,6 @@
"ios": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.plugin/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.plugin/properties/android/properties/disabled"
},
Expand Down Expand Up @@ -528,7 +520,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of URLs that will be injected on top of the Podfile as sources"
},
"podDependencies": {
"type": "array",
Expand All @@ -546,7 +539,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of strings that will be injected on top of the Podfile"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -744,10 +738,17 @@
"items": {
"$ref": "#/definitions/rnv.plugin/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
},
"didReceiveNotificationResponse": {
"type": "array",
"items": {
"$ref": "#/definitions/rnv.plugin/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
}
},
"required": [
"willPresent"
"willPresent",
"didReceiveNotificationResponse"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -813,9 +814,6 @@
"tizen": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.plugin/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.plugin/properties/android/properties/disabled"
},
Expand Down
26 changes: 12 additions & 14 deletions packages/core/jsonSchema/rnv.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@
"android": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": true,
"description": "Marks plugin platform enabled or disabled"
},
"disabled": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -475,9 +470,6 @@
"ios": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/android/properties/disabled"
},
Expand Down Expand Up @@ -536,7 +528,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of URLs that will be injected on top of the Podfile as sources"
},
"podDependencies": {
"type": "array",
Expand All @@ -554,7 +547,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "Array of strings that will be injected on top of the Podfile"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -752,10 +746,17 @@
"items": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
},
"didReceiveNotificationResponse": {
"type": "array",
"items": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/ios/properties/templateXcode/properties/AppDelegate_mm/properties/appDelegateMethods/properties/application/properties/didFinishLaunchingWithOptions/items"
}
}
},
"required": [
"willPresent"
"willPresent",
"didReceiveNotificationResponse"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -821,9 +822,6 @@
"tizen": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/android/properties/enabled"
},
"disabled": {
"$ref": "#/definitions/rnv.plugins/properties/pluginTemplates/additionalProperties/properties/android/properties/disabled"
},
Expand Down

0 comments on commit 73bf6f6

Please sign in to comment.