From 3309ea63f67a1650478ba98ebcc41e048a9cc228 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 22 Nov 2023 13:51:20 +0000 Subject: [PATCH] [PRODENG-211] improved ADF CLI compilation (#9105) * reduce npm log noise to errors * remove unused ts config * improve CLI build config * use monorepo libs when building CLI * [ci:force] minor polishing --- angular.json | 3 +- lib/cli/scripts/audit.ts | 2 +- lib/cli/scripts/changelog.ts | 2 +- lib/cli/scripts/init-aae-env.ts | 7 +++ lib/cli/scripts/init-acs-env.ts | 1 + lib/cli/scripts/init-aps-env.ts | 7 +++ lib/cli/scripts/licenses.ts | 2 +- lib/cli/scripts/scan-env.ts | 5 ++ lib/cli/tsconfig.json | 1 + lib/cli/tsconfig.lib.prod.json | 9 --- package-lock.json | 101 ++++++++++++++++++++++++++++++++ package.json | 5 ++ scripts/update-version.sh | 9 ++- 13 files changed, 135 insertions(+), 19 deletions(-) delete mode 100644 lib/cli/tsconfig.lib.prod.json diff --git a/angular.json b/angular.json index ac5ba5eb1b..3d689bb188 100644 --- a/angular.json +++ b/angular.json @@ -1074,8 +1074,7 @@ "build": { "builder": "nx:run-commands", "options": { - "command": - "cd lib/cli && npm i && npm run dist", + "command": "cd lib/cli && npm run dist", "stylePreprocessorOptions": { "includePaths": [ "lib", "lib/core/src/lib" diff --git a/lib/cli/scripts/audit.ts b/lib/cli/scripts/audit.ts index 3eb5e2e7ac..57dbb0513e 100644 --- a/lib/cli/scripts/audit.ts +++ b/lib/cli/scripts/audit.ts @@ -41,7 +41,7 @@ export default function main(_args: string[], workingDir: string) { if (argv.includes('-h') || argv.includes('--help')) { program.outputHelp(); - return; + exit(0); } let packagePath = path.resolve(workingDir, 'package.json'); diff --git a/lib/cli/scripts/changelog.ts b/lib/cli/scripts/changelog.ts index 310f04b761..641f27f927 100644 --- a/lib/cli/scripts/changelog.ts +++ b/lib/cli/scripts/changelog.ts @@ -155,7 +155,7 @@ export default function main(_args: string[], workingDir: string) { if (argv.includes('-h') || argv.includes('--help')) { program.outputHelp(); - return; + exit(0); } const dir = path.resolve(program.dir || workingDir); diff --git a/lib/cli/scripts/init-aae-env.ts b/lib/cli/scripts/init-aae-env.ts index 6d6a4d7032..25de52dad3 100755 --- a/lib/cli/scripts/init-aae-env.ts +++ b/lib/cli/scripts/init-aae-env.ts @@ -124,6 +124,7 @@ async function getApplications(): Promise<{ list: { entries: any[] } }> { } catch (error) { logger.error(`Get application by status ${error.status} `); isValid = false; + return null; } } @@ -158,6 +159,7 @@ function getDescriptors() { } catch (error) { logger.error(`Get Descriptors ${error.status} `); isValid = false; + return null; } } @@ -192,6 +194,7 @@ function getProjects() { } catch (error) { logger.error('Get Projects' + error.status); isValid = false; + return null; } } @@ -227,6 +230,7 @@ function getProjectRelease(projectId: string) { } catch (error) { logger.error('Get Projects Release' + error.status); isValid = false; + return null; } } @@ -297,6 +301,7 @@ function deleteProject(projectId: string) { } catch (error) { logger.error('Delete project error' + error.status); isValid = false; + return null; } } @@ -373,6 +378,7 @@ function deleteDescriptor(name: string) { } catch (error) { logger.error('Delete descriptor' + error.status); isValid = false; + return null; } } @@ -408,6 +414,7 @@ function deploy(model: any) { } catch (error) { logger.error('Deploy post' + error.status); isValid = false; + return null; } } diff --git a/lib/cli/scripts/init-acs-env.ts b/lib/cli/scripts/init-acs-env.ts index 0788b0ff31..59c314ca9f 100755 --- a/lib/cli/scripts/init-acs-env.ts +++ b/lib/cli/scripts/init-acs-env.ts @@ -148,6 +148,7 @@ async function lockFile(nodeId: string): Promise { return result; } catch (error) { logger.error('Failed to lock file with error: ', error.stack); + return null; } } diff --git a/lib/cli/scripts/init-aps-env.ts b/lib/cli/scripts/init-aps-env.ts index 030bb101be..fcaf6ae848 100755 --- a/lib/cli/scripts/init-aps-env.ts +++ b/lib/cli/scripts/init-aps-env.ts @@ -190,6 +190,7 @@ async function hasDefaultTenant(tenantId: number, tenantName: string): Promise { return defaultApp && defaultApp.length > 0; } catch (error) { logger.error(`Aps app failed to import/Publish!`); + return false; } } @@ -306,6 +309,7 @@ async function importPublishApp(appName: string): Promise { return false; } catch (error) { logger.error(`Aps not able to check the license` ); + return false; } } @@ -378,6 +383,7 @@ async function getDefaultApsUsersFromRealm() { return apsDefaultUsers; } catch (error) { logger.error(`APS: not able to fetch user: ${error.message}` ); + return null; } } @@ -403,6 +409,7 @@ async function isContentRepoPresent(tenantId: number, contentName: string): Prom return !!contentRepos.data.find(repo => repo.name === contentName); } catch (error) { logger.error(`APS: not able to create content: ${error.message}` ); + return null; } } diff --git a/lib/cli/scripts/licenses.ts b/lib/cli/scripts/licenses.ts index c0d5834a26..6c29544ece 100644 --- a/lib/cli/scripts/licenses.ts +++ b/lib/cli/scripts/licenses.ts @@ -107,7 +107,7 @@ export default function main(_args: string[], workingDir: string) { if (argv.includes('-h') || argv.includes('--help')) { program.outputHelp(); - return; + exit(0); } let packagePath = path.resolve(workingDir, 'package.json'); diff --git a/lib/cli/scripts/scan-env.ts b/lib/cli/scripts/scan-env.ts index d8a6bb1d23..971286fa16 100644 --- a/lib/cli/scripts/scan-env.ts +++ b/lib/cli/scripts/scan-env.ts @@ -215,6 +215,7 @@ async function getPeopleCount(skipCount: number = 0): Promise { return result; } catch (error) { handleError(error); + return null; } } @@ -232,6 +233,7 @@ async function getHomeFoldersCount(): Promise { return homesFolderApiResult.list.pagination.totalItems; } catch (error) { handleError(error); + return 0; } } @@ -246,6 +248,7 @@ async function getGroupsCount(): Promise { return groupsApiResult.list.pagination.totalItems; } catch (error) { handleError(error); + return 0; } } @@ -260,6 +263,7 @@ async function getSitesCount(): Promise { return sitesApiResult.list.pagination.totalItems; } catch (error) { handleError(error); + return 0; } } @@ -282,6 +286,7 @@ async function getFilesCount(): Promise { return searchApiResult.list.pagination.totalItems; } catch (error) { handleError(error); + return 0; } } diff --git a/lib/cli/tsconfig.json b/lib/cli/tsconfig.json index 65c0045797..dc0fa2dea1 100644 --- a/lib/cli/tsconfig.json +++ b/lib/cli/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { "declaration": true, "module": "commonjs", diff --git a/lib/cli/tsconfig.lib.prod.json b/lib/cli/tsconfig.lib.prod.json deleted file mode 100644 index 2a2faa884c..0000000000 --- a/lib/cli/tsconfig.lib.prod.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.lib.json", - "compilerOptions": { - "declarationMap": false - }, - "angularCompilerOptions": { - "compilationMode": "partial" - } -} diff --git a/package-lock.json b/package-lock.json index b62cd22e3f..28b23e5ff2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,6 +77,7 @@ "@storybook/angular": "6.5.16", "@storybook/builder-webpack5": "6.5.10", "@storybook/manager-webpack5": "6.5.10", + "@types/ejs": "^3.1.5", "@types/event-emitter": "^0.3.3", "@types/jasmine": "4.0.3", "@types/jasminewd2": "~2.0.2", @@ -86,6 +87,7 @@ "@types/node": "18.0.0", "@types/pdfjs-dist": "^2.10.378", "@types/selenium-webdriver": "^4.0.11", + "@types/shelljs": "^0.8.15", "@typescript-eslint/eslint-plugin": "5.59.8", "@typescript-eslint/parser": "5.62.0", "@typescript-eslint/typescript-estree": "6.7.0", @@ -94,6 +96,7 @@ "css-loader": "^6.8.1", "dotenv": "16.1.3", "editorjs-text-color-plugin": "1.13.1", + "ejs": "^3.1.9", "eslint": "^8.47.0", "eslint-config-prettier": "^8.10.0", "eslint-plugin-ban": "^1.6.0", @@ -140,6 +143,8 @@ "rimraf": "^5.0.5", "sass-loader": "13.3.2", "selenium-webdriver": "4.1.0", + "shelljs": "^0.8.5", + "spdx-license-list": "^6.8.0", "stylelint": "^14.15.0", "stylelint-config-standard-scss": "^3.0.0", "ts-node": "^10.9.1", @@ -21008,6 +21013,12 @@ "@types/node": "*" } }, + "node_modules/@types/ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-nv+GSx77ZtXiJzwKdsASqi+YQ5Z7vwHsTP0JY2SiQgjGckkBRKZnk8nIM+7oUZ1VCtuTz0+By4qVR7fqzp/Dfg==", + "dev": true + }, "node_modules/@types/eslint": { "version": "8.37.0", "license": "MIT", @@ -21348,6 +21359,26 @@ "@types/node": "*" } }, + "node_modules/@types/shelljs": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.15.tgz", + "integrity": "sha512-vzmnCHl6hViPu9GNLQJ+DZFd6BQI2DBTUeOvYHqkWQLMfKAAQYMb/xAmZkTogZI/vqXHCWkqDRymDI5p0QTi5Q==", + "dev": true, + "dependencies": { + "@types/glob": "~7.2.0", + "@types/node": "*" + } + }, + "node_modules/@types/shelljs/node_modules/@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dev": true, + "dependencies": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, "node_modules/@types/sockjs": { "version": "0.3.33", "dev": true, @@ -45462,6 +45493,64 @@ "node": ">=8" } }, + "node_modules/shelljs": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", + "integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==", + "dev": true, + "dependencies": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, + "bin": { + "shjs": "bin/shjs" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/shelljs/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/shelljs/node_modules/interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/shelljs/node_modules/rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", + "dev": true, + "dependencies": { + "resolve": "^1.1.6" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/side-channel": { "version": "1.0.4", "license": "MIT", @@ -45978,6 +46067,18 @@ "version": "3.0.13", "license": "CC0-1.0" }, + "node_modules/spdx-license-list": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/spdx-license-list/-/spdx-license-list-6.8.0.tgz", + "integrity": "sha512-5UdM7r9yJ1EvsPQZWfa41AZjLQngl9iMMysm9XBW7Lqhq7aF8cllfqjS+rFCHB8FFMGSM0yFWue2LUV9mR0QzQ==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/spdx-ranges": { "version": "2.1.1", "dev": true, diff --git a/package.json b/package.json index 876a31e57a..ab69b00064 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "@storybook/angular": "6.5.16", "@storybook/builder-webpack5": "6.5.10", "@storybook/manager-webpack5": "6.5.10", + "@types/ejs": "^3.1.5", "@types/event-emitter": "^0.3.3", "@types/jasmine": "4.0.3", "@types/jasminewd2": "~2.0.2", @@ -130,6 +131,7 @@ "@types/node": "18.0.0", "@types/pdfjs-dist": "^2.10.378", "@types/selenium-webdriver": "^4.0.11", + "@types/shelljs": "^0.8.15", "@typescript-eslint/eslint-plugin": "5.59.8", "@typescript-eslint/parser": "5.62.0", "@typescript-eslint/typescript-estree": "6.7.0", @@ -138,6 +140,7 @@ "css-loader": "^6.8.1", "dotenv": "16.1.3", "editorjs-text-color-plugin": "1.13.1", + "ejs": "^3.1.9", "eslint": "^8.47.0", "eslint-config-prettier": "^8.10.0", "eslint-plugin-ban": "^1.6.0", @@ -184,6 +187,8 @@ "rimraf": "^5.0.5", "sass-loader": "13.3.2", "selenium-webdriver": "4.1.0", + "shelljs": "^0.8.5", + "spdx-license-list": "^6.8.0", "stylelint": "^14.15.0", "stylelint-config-standard-scss": "^3.0.0", "ts-node": "^10.9.1", diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 46988b7bfe..36a256e572 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -77,7 +77,7 @@ update_library_version() { fi cd $DESTDIR - npm version --allow-same-version --no-git-tag-version --force $VERSION + npm version --allow-same-version --no-git-tag-version --force --loglevel=error $VERSION } update_dependency_version() { @@ -156,10 +156,9 @@ then exit 1 fi +echo "====== UPDATE COMPONENT LIBRARIES ======" cd "$DIR/../" -echo "====== UPDATE COMPONENTS ======" - for PROJECT in ${projects[@]} do update_library_version $PROJECT @@ -185,10 +184,10 @@ if $JS_API == true; then fi # bump root package.json -npm version --allow-same-version --no-git-tag-version --force $VERSION +npm version --allow-same-version --no-git-tag-version --force --loglevel=error $VERSION echo "====== UPDATE DEMO SHELL ======" DESTDIR="$DIR/../demo-shell/" cd $DESTDIR -npm version --allow-same-version --no-git-tag-version --force $VERSION +npm version --allow-same-version --no-git-tag-version --force --loglevel=error $VERSION