diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index 398d3708fa..187ee7d13c 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -38,7 +38,8 @@ "debug:schematics-dist": "./node_modules/.bin/ng g ./dist/packages/schematics/collection.json:proxy-add --module __default --apiName __default --source __default --target __default --url http://localhost:4300 --service-type application", "ci": "yarn affected:lint && yarn affected:build && yarn affected:test", "lerna": "lerna", - "migrate-nx": "yarn nx migrate --run-migrations" + "migrate-nx": "yarn nx migrate --run-migrations", + "copy-to:app": "cd scripts && yarn && yarn copy-to-templates -t app" }, "private": true, "devDependencies": { diff --git a/npm/ng-packs/scripts/copy-packages-to-templates.ts b/npm/ng-packs/scripts/copy-packages-to-templates.ts index dd605db994..659d2f192d 100644 --- a/npm/ng-packs/scripts/copy-packages-to-templates.ts +++ b/npm/ng-packs/scripts/copy-packages-to-templates.ts @@ -1,7 +1,7 @@ -import execa from 'execa'; -import fse from 'fs-extra'; -import fs from 'fs'; -import program from 'commander'; +import execa from "execa"; +import fse from "fs-extra"; +import fs from "fs"; +import program from "commander"; const defaultTemplates = ['app', 'app-nolayers', 'module']; const defaultTemplatePath = '../../../templates'; @@ -17,21 +17,32 @@ const packageMap = { 'tenant-management': 'ng.tenant-management', 'theme-basic': 'ng.theme.basic', 'theme-shared': 'ng.theme.shared', - 'schematics':'ng.schematics', - oauth:'ng.oauth' + schematics: 'ng.schematics', + oauth: 'ng.oauth', }; program.option('-t, --templates ', 'template dirs', false); program.option('-p, --template-path ', 'root template path', false); +program.option( + '-e, --use-existing-build ', + "don't build packages if dist folder exists", + false, +); +program.option('-i, --noInstall', 'skip package installation', false); +program.option('-a, --absolute-dir ', 'Absolute angular directory', false); program.parse(process.argv); const templates = program.templates ? program.templates.split(',') : defaultTemplates; const templateRootPath = program.templatePath ? program.templatePath : defaultTemplatePath; (async () => { - await execa('yarn', ['build:all'], { - stdout: 'inherit', - cwd:'../' - }); + if (!program.useExistingBuild) { + await execa('yarn', ['build:all'], { + stdout: 'inherit', + cwd: '../', + }); + } - await installPackages(); + if (!program.noInstall) { + await installPackages(); + } await removeAbpPackages(); @@ -41,11 +52,17 @@ const templateRootPath = program.templatePath ? program.templatePath : defaultTe async function runEachTemplate( handler: (template: string, templatePath?: string) => void | Promise, ) { - for (var template of templates) { - const templatePath = `${templateRootPath}/${template}/angular`; - const result = handler(template, templatePath); + if (program.absoluteDir) { + const result = handler('', program.absoluteDir); result instanceof Promise ? await result : result; + } else { + for (var template of templates) { + const templatePath = `${templateRootPath}/${template}/angular`; + const result = handler(template, templatePath); + result instanceof Promise ? await result : result; + } } + } async function installPackages() {