Browse Source

add absolute project parameter to copy script

pull/15797/head
muhammedaltug 4 years ago
parent
commit
1d0fe5b765
  1. 3
      npm/ng-packs/package.json
  2. 45
      npm/ng-packs/scripts/copy-packages-to-templates.ts

3
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", "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", "ci": "yarn affected:lint && yarn affected:build && yarn affected:test",
"lerna": "lerna", "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, "private": true,
"devDependencies": { "devDependencies": {

45
npm/ng-packs/scripts/copy-packages-to-templates.ts

@ -1,7 +1,7 @@
import execa from 'execa'; import execa from "execa";
import fse from 'fs-extra'; import fse from "fs-extra";
import fs from 'fs'; import fs from "fs";
import program from 'commander'; import program from "commander";
const defaultTemplates = ['app', 'app-nolayers', 'module']; const defaultTemplates = ['app', 'app-nolayers', 'module'];
const defaultTemplatePath = '../../../templates'; const defaultTemplatePath = '../../../templates';
@ -17,21 +17,32 @@ const packageMap = {
'tenant-management': 'ng.tenant-management', 'tenant-management': 'ng.tenant-management',
'theme-basic': 'ng.theme.basic', 'theme-basic': 'ng.theme.basic',
'theme-shared': 'ng.theme.shared', 'theme-shared': 'ng.theme.shared',
'schematics':'ng.schematics', schematics: 'ng.schematics',
oauth:'ng.oauth' oauth: 'ng.oauth',
}; };
program.option('-t, --templates <templates>', 'template dirs', false); program.option('-t, --templates <templates>', 'template dirs', false);
program.option('-p, --template-path <templatePath>', 'root template path', false); program.option('-p, --template-path <templatePath>', 'root template path', false);
program.option(
'-e, --use-existing-build <useExistingBuild>',
"don't build packages if dist folder exists",
false,
);
program.option('-i, --noInstall', 'skip package installation', false);
program.option('-a, --absolute-dir <absoluteDir>', 'Absolute angular directory', false);
program.parse(process.argv); program.parse(process.argv);
const templates = program.templates ? program.templates.split(',') : defaultTemplates; const templates = program.templates ? program.templates.split(',') : defaultTemplates;
const templateRootPath = program.templatePath ? program.templatePath : defaultTemplatePath; const templateRootPath = program.templatePath ? program.templatePath : defaultTemplatePath;
(async () => { (async () => {
await execa('yarn', ['build:all'], { if (!program.useExistingBuild) {
stdout: 'inherit', await execa('yarn', ['build:all'], {
cwd:'../' stdout: 'inherit',
}); cwd: '../',
});
}
await installPackages(); if (!program.noInstall) {
await installPackages();
}
await removeAbpPackages(); await removeAbpPackages();
@ -41,11 +52,17 @@ const templateRootPath = program.templatePath ? program.templatePath : defaultTe
async function runEachTemplate( async function runEachTemplate(
handler: (template: string, templatePath?: string) => void | Promise<any>, handler: (template: string, templatePath?: string) => void | Promise<any>,
) { ) {
for (var template of templates) { if (program.absoluteDir) {
const templatePath = `${templateRootPath}/${template}/angular`; const result = handler('', program.absoluteDir);
const result = handler(template, templatePath);
result instanceof Promise ? await result : result; 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() { async function installPackages() {

Loading…
Cancel
Save