Skip to content

Commit

Permalink
Merge branch 'main' into fix/tizen_app_package
Browse files Browse the repository at this point in the history
* main: (35 commits)
  add ts-coverage tool
  update json schema, fix config loading
  any killing spree
  type coverage, kill any
  types for program, workspaces, runtimes
  typefy context cli
  strong type for c.program
  kill any
  rename RenativeConfigFile to ConfigFileBuildConfig
  add runtime config schema, cleanup
  npm types fixes
  typed npm package files
  clean code
  fix/buildHooks_path
  context type hardening
  typed project template
  typed plugin templates
  finish config  file type migration
  more ts fixes
  ts fixes
  ...

# Conflicts:
#	packages/template-starter/package.json
  • Loading branch information
pavjacko committed Oct 20, 2023
2 parents 4deca94 + 19e6dd6 commit 4658af9
Show file tree
Hide file tree
Showing 105 changed files with 1,719 additions and 912 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ lib

lerna-debug.log
yarn-error.log
.rnv
.rnv
coverage-ts
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"bootstrap": "yarn run link:rnv && npx lerna bootstrap && yarn build",
"bootstrap-clean": "rm -rf ./node_modules; npx lerna clean --yes && yarn bootstrap",
"build": "lerna run build",
"circular": "npx madge --circular --extensions ts --exclude '\\.(d.ts)$' ./packages",
"report-circular": "npx madge --circular --extensions ts --exclude '\\.(d.ts)$' ./packages",
"report-ts-coverage": "typescript-coverage-report -p ./packages/core/tsconfig.json -t 99 -i lib",
"report-jest": "jest --coverage",
"compile": "npx lerna run compile",
"deploy:canary": "yarn pre-publish && npx lerna publish from-package --dist-tag canary && git push origin HEAD",
"deploy:feat": "yarn pre-publish && npx lerna publish from-package --dist-tag feat && git push origin HEAD",
Expand All @@ -79,7 +81,6 @@
"prettier-write-json": "npx prettier '**/{package.json,renative.plugins.json,renative.json}' --write --config .prettierrc.js",
"sanity": "yarn compile && yarn lint && yarn test",
"test": "jest",
"test-cover": "jest --coverage",
"watch": "npx lerna exec yarn watch --parallel",
"watch-alt": "npx lerna run compile & npx lerna watch -- lerna run compile"
},
Expand Down Expand Up @@ -116,8 +117,8 @@
"madge": "6.1.0",
"prettier": "2.3.1",
"ts-jest": "^27.0.7",
"ttab": "^0.7.2",
"typescript": "5.2.2"
"typescript": "5.2.2",
"typescript-coverage-report": "0.8.0"
},
"engines": {
"node": ">=18.0.0",
Expand Down
12 changes: 11 additions & 1 deletion packages/build-hooks-git/src/git.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { RnvContext, logHook } from '@rnv/core';
import { RnvContext, logError, logHook } from '@rnv/core';
import path from 'path';
import simpleGit from 'simple-git';

export const gitCommit = async (c: RnvContext) => {
const v = c.files.project?.package?.version;

if (!v) {
logError('Version not found in package.json. cannot perform git commit');
return;
}

const baseDir = path.join(c.paths.project.dir);
logHook(`gitCommitAndTagVersion v${v}`);
const git = simpleGit({ baseDir });
Expand All @@ -18,6 +23,11 @@ export const gitCommit = async (c: RnvContext) => {
export const gitTag = async (c: RnvContext) => {
const v = c.files.project.package.version;

if (!v) {
logError('Version not found in package.json. cannot perform git tag');
return;
}

const baseDir = path.join(c.paths.project.dir);
logHook(`gitTagAndPush v${v}`);
const git = simpleGit({ baseDir });
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const run = () => {

program.version(packageJson.version, '-v, --version', 'output current version');

PARAMS.withAll().forEach((param: any) => {
PARAMS.withAll().forEach((param) => {
let cmd = '';
if (param.shortcut) {
cmd += `-${param.shortcut}, `;
Expand All @@ -34,7 +34,7 @@ export const run = () => {
program.option(cmd, param.description);
});

program.arguments('<cmd> [option]').action((cmd: any, option: any) => {
program.arguments('<cmd> [option]').action((cmd, option) => {
cmdValue = cmd;
cmdOption = option;
});
Expand All @@ -43,5 +43,5 @@ export const run = () => {

executeRnv({ cmd: cmdValue, subCmd: cmdOption, program, process, spinner: Spinner, prompt: Prompt, logger: Logger })
.then(() => logComplete(!getContext().runtime.keepSessionActive))
.catch((e: any) => logError(e, true));
.catch((e: unknown) => logError(e, true));
};
29 changes: 18 additions & 11 deletions packages/cli/src/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import {
generateDefaultChalk,
RnvApiLogger,
RnvApiChalk,
RnvApiChalkFn,
} from '@rnv/core';

const ICN_ROCKET = isSystemWin ? 'RNV' : '🚀';
const ICN_UNICORN = isSystemWin ? 'unicorn' : '🦄';
const _chalkCols = generateDefaultChalk();
const _chalkMono: any = {
const _chalkMono = {
..._chalkCols,
};
let currentChalk: RnvApiChalk = _chalk;
let RNV = 'ReNative';
const PRIVATE_PARAMS = ['-k', '--key'];
let _currentProcess: any;
let _currentProcess: NodeJS.Process;
let _isInfoEnabled = false;
let _infoFilter: Array<string> = [];
// let _c: RnvContext;
Expand Down Expand Up @@ -262,9 +263,9 @@ export const logSummary = (header = 'SUMMARY') => {
}

if (ctx.files?.project?.config?.defaults) {
const defaultProjectConfigs = ctx.files.project.config.defaults;
if (defaultProjectConfigs?.template) {
str += printIntoBox(`Master Template: ${_highlightColor(defaultProjectConfigs.template)}`);
const currentTemplate = ctx.files.project.config?.currentTemplate;
if (currentTemplate) {
str += printIntoBox(`Master Template: ${_highlightColor(currentTemplate)}`);
}
}

Expand Down Expand Up @@ -323,7 +324,7 @@ const _sanitizePaths = (msg: string) => {

const TASK_COUNTER: Record<string, number> = {};

export const logTask = (task: string, customChalk?: any) => {
export const logTask = (task: string, customChalk?: string | RnvApiChalkFn) => {
if (!TASK_COUNTER[task]) TASK_COUNTER[task] = 0;
TASK_COUNTER[task] += 1;
const taskCount = currentChalk.grey(`[${TASK_COUNTER[task]}]`);
Expand Down Expand Up @@ -374,7 +375,7 @@ type PrintJsonPayload = {
type: string;
task?: string;
message: string;
hook?: any;
hook?: string;
level?: string;
};

Expand Down Expand Up @@ -411,7 +412,7 @@ export const logHook = (hook = '', msg = '') => {
);
};

export const logWarning = (msg: string | boolean) => {
export const logWarning = (msg: string | boolean | unknown) => {
const msgSn = typeof msg === 'string' ? _sanitizePaths(msg) : String(msg);
if (_jsonOnly) {
return _printJson({
Expand Down Expand Up @@ -477,7 +478,13 @@ export const logSuccess = (msg: string) => {
logAndSave(currentChalk.magenta(`[ success ]${_getCurrentTask()} ${_sanitizePaths(msg)}`));
};

export const logError = (e: Error | string, isEnd = false, skipAnalytics = false) => {
export const logError = (e: Error | string | unknown, isEnd = false, skipAnalytics = false) => {
let err = '';
if (typeof e === 'string') {
err = e;
} else if (e instanceof Error) {
err = e.message;
}
const ctx = getContext();
const api = getApi();
if (!skipAnalytics) {
Expand All @@ -491,15 +498,15 @@ export const logError = (e: Error | string, isEnd = false, skipAnalytics = false
arch: ctx.process?.arch,
node: ctx.process?.versions?.node,
};
api.analytics.captureException(e, { extra });
api.analytics.captureException(err, { extra });
}

if (_jsonOnly) {
_printJson({
type: 'log',
level: 'error',
task: stripAnsi(_getCurrentTask()),
message: stripAnsi(_sanitizePaths(e instanceof Error ? e.message : e)),
message: stripAnsi(_sanitizePaths(err)),
});
} else if (e && e instanceof Error && e.message) {
logAndSave(currentChalk.red(`[ error ]${_getCurrentTask()} ${e.message}\n${e.stack}`), isEnd);
Expand Down
10 changes: 2 additions & 8 deletions packages/core/jsonSchema/rnv.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,11 @@
"type": "boolean"
},
"storeFile": {
"type": "array",
"items": {
"type": "string"
},
"type": "string",
"description": "Name of the store file in android project"
},
"keyAlias": {
"type": "array",
"items": {
"type": "string"
},
"type": "string",
"description": "Key alias of the store file in android project"
},
"templateAndroid": {
Expand Down
15 changes: 15 additions & 0 deletions packages/core/jsonSchema/rnv.global.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,26 @@
},
"description": "Define your sdk configurations"
},
"projectTemplates": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
"appConfigsPath": {
"type": "string",
"description": "Enables you to define custom global appConfigs location that every project will automatically use"
},
"$schema": {
"type": "string",
"description": "schema definition"
}
},
"required": [
"projectTemplates"
],
"additionalProperties": false
}
},
Expand Down
3 changes: 0 additions & 3 deletions packages/core/jsonSchema/rnv.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
},
"additionalProperties": false
},
"extend": {
"type": "string"
},
"$schema": {
"type": "string",
"description": "schema definition"
Expand Down
93 changes: 81 additions & 12 deletions packages/core/jsonSchema/rnv.private.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,97 @@
"rnv.private": {
"type": "object",
"properties": {
"storePassword": {
"type": "string",
"description": "> WARNING. this prop is sensitive and should not be stored in standard `renative.json` configs. use `renative.private.json` files instead!\n\nstorePassword for keystore file"
},
"keyPassword": {
"type": "string",
"description": "> WARNING. this prop is sensitive and should not be stored in standard `renative.json` configs. use `renative.private.json` files instead!\n\nkeyPassword for keystore file"
},
"private": {
"type": "object",
"additionalProperties": {},
"description": "Special object which contains private info. this object should be used only in `renative.private.json` files and never commited to your repository. Private files usually reside in your workspace and are subject to crypto encryption if enabled. RNV will warn you if it finds private key in your regular `renative.json` file"
},
"platforms": {
"type": "object",
"properties": {
"android": {
"type": "object",
"properties": {
"storePassword": {
"type": "string",
"description": "> WARNING. this prop is sensitive and should not be stored in standard `renative.json` configs. use `renative.private.json` files instead!\n\nstorePassword for keystore file"
},
"keyPassword": {
"type": "string",
"description": "> WARNING. this prop is sensitive and should not be stored in standard `renative.json` configs. use `renative.private.json` files instead!\n\nkeyPassword for keystore file"
},
"storeFile": {
"type": "string",
"description": "Name of the store file in android project"
},
"keyAlias": {
"type": "string",
"description": "Key alias of the store file in android project"
}
},
"additionalProperties": false
},
"androidtv": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/android"
},
"androidwear": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/android"
},
"firetv": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/android"
},
"ios": {
"type": "object",
"properties": {},
"additionalProperties": false
},
"tvos": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"tizen": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"tizenmobile": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"tizenwatch": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"webos": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"web": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"webtv": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"chromecast": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"kaios": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"macos": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"linux": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"windows": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
},
"xbox": {
"$ref": "#/definitions/rnv.private/properties/platforms/properties/ios"
}
},
"additionalProperties": false
},
"$schema": {
"type": "string",
"description": "schema definition"
}
},
"required": [
"storePassword",
"keyPassword"
],
"additionalProperties": false
}
},
Expand Down
Loading

0 comments on commit 4658af9

Please sign in to comment.