@nu-art/build-and-install 0.204.10 → 0.204.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/logic/ProjectManager.js +0 -1
- package/package.json +1 -1
- package/phases/phases.js +43 -13
package/logic/ProjectManager.js
CHANGED
package/package.json
CHANGED
package/phases/phases.js
CHANGED
|
@@ -48,6 +48,7 @@ const CONST_ProjectVersionKey = 'APP_VERSION';
|
|
|
48
48
|
const CONST_ProjectDependencyKey = 'APP_VERSION_DEPENDENCY';
|
|
49
49
|
const CONST_TS_Config = `tsconfig.json`;
|
|
50
50
|
const CONST_RunningRoot = process.cwd();
|
|
51
|
+
const CONST_VersionApp = 'version-app.json';
|
|
51
52
|
const pathToProjectTS_Config = (0, tools_1.convertToFullPath)(`./.config/${CONST_TS_Config}`);
|
|
52
53
|
const pathToProjectEslint = (0, tools_1.convertToFullPath)('./.config/.eslintrc.js');
|
|
53
54
|
const runInDebug = false;
|
|
@@ -387,11 +388,12 @@ exports.Phase_PrepareCompile = {
|
|
|
387
388
|
compileActions[sourceFolder] = async () => {
|
|
388
389
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
389
390
|
projectScreen.updateOrCreatePackage(pkg.name, 'Compiling');
|
|
391
|
+
const counter = timeCounter();
|
|
390
392
|
const commando = nvm_1.NVM.createCommando();
|
|
391
393
|
await commando
|
|
392
394
|
.append(`tsc -p "${pathToLocalTsConfig}" --rootDir "${sourceFolder}" --outDir "${pkg.output}"`)
|
|
393
395
|
.execute();
|
|
394
|
-
projectScreen.updateOrCreatePackage(pkg.name,
|
|
396
|
+
projectScreen.updateOrCreatePackage(pkg.name, `Compiled (${counter.format('mm:ss.zzz')})`);
|
|
395
397
|
};
|
|
396
398
|
}
|
|
397
399
|
};
|
|
@@ -425,6 +427,7 @@ exports.Phase_Compile = {
|
|
|
425
427
|
return;
|
|
426
428
|
try {
|
|
427
429
|
const otherFiles = [
|
|
430
|
+
'json',
|
|
428
431
|
'scss',
|
|
429
432
|
'svg',
|
|
430
433
|
'png',
|
|
@@ -444,6 +447,9 @@ exports.Phase_Compile = {
|
|
|
444
447
|
const folder = 'main';
|
|
445
448
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
446
449
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
450
|
+
const pathToVersionAppJSON = `${CONST_RunningRoot}/${CONST_VersionApp}`;
|
|
451
|
+
//copy version-app.json file
|
|
452
|
+
const versionAppJSON = await fs_1.promises.readFile(pathToVersionAppJSON, { encoding: 'utf-8' });
|
|
447
453
|
// only read if exists
|
|
448
454
|
let inPackageTsConfig = '';
|
|
449
455
|
if (fs.existsSync(pathToLocalTsConfig))
|
|
@@ -455,7 +461,9 @@ exports.Phase_Compile = {
|
|
|
455
461
|
}
|
|
456
462
|
// --- HERE ---
|
|
457
463
|
await fs_1.promises.writeFile(`${pkg.output}/${consts_1.CONST_PackageJSON}`, JSON.stringify(pkg.packageJsonOutput, null, 2), { encoding: 'utf-8' });
|
|
458
|
-
if (pkg.type
|
|
464
|
+
if (pkg.type === types_1.PackageType_FirebaseFunctionsApp || pkg.type === types_1.PackageType_FirebaseHostingApp)
|
|
465
|
+
await fs_1.promises.writeFile(`${sourceFolder}/${CONST_VersionApp}`, versionAppJSON, { encoding: 'utf-8' });
|
|
466
|
+
if (pkg.type === 'firebase-functions-app') {
|
|
459
467
|
pkg.packageJsonRuntime.main = pkg.packageJsonRuntime.main.replace('dist/', '');
|
|
460
468
|
pkg.packageJsonRuntime.types = pkg.packageJsonRuntime.types.replace('dist/', '');
|
|
461
469
|
await fs_1.promises.writeFile(`${pkg.output}/${consts_1.CONST_PackageJSON}`, JSON.stringify(pkg.packageJsonRuntime, null, 2), { encoding: 'utf-8' });
|
|
@@ -579,17 +587,15 @@ exports.Phase_Launch = {
|
|
|
579
587
|
filter: async (pkg) => { var _a; return !!((_a = pkg.name.match(new RegExp(params_1.RuntimeParams.launch))) === null || _a === void 0 ? void 0 : _a[0]) && (pkg.type === 'firebase-functions-app' || pkg.type === 'firebase-hosting-app'); },
|
|
580
588
|
action: async (pkg) => {
|
|
581
589
|
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
582
|
-
projectScreen.updateOrCreatePackage(pkg.name, '
|
|
590
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Launching...');
|
|
583
591
|
if (pkg.type === 'firebase-functions-app') {
|
|
584
592
|
await (0, ts_common_1.sleep)(1000 * counter++);
|
|
585
593
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${pkg.envConfig.basePort + i}`);
|
|
586
594
|
const command = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
587
|
-
.cd(pkg.path)
|
|
595
|
+
.cd(pkg.path)
|
|
588
596
|
.append(`nvm use`)
|
|
589
|
-
.append(`echo RUNNING PACKAGE1 ${pkg.name}`)
|
|
590
597
|
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
591
|
-
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
592
|
-
.append(`echo RUNNING PACKAGE2 ${pkg.name}`);
|
|
598
|
+
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`);
|
|
593
599
|
command.append(`firebase emulators:start --export-on-exit --import=.trash/data ${runInDebug ? `--inspect-functions ${pkg.envConfig.ssl}` : ''}`);
|
|
594
600
|
return command
|
|
595
601
|
.execute();
|
|
@@ -597,11 +603,12 @@ exports.Phase_Launch = {
|
|
|
597
603
|
if (pkg.type === 'firebase-hosting-app')
|
|
598
604
|
return nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
599
605
|
.cd(pkg.path)
|
|
606
|
+
.append(`array=($(lsof -ti:${[pkg.envConfig.basePort - 1].join(',')}))`)
|
|
607
|
+
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
600
608
|
.append(`nvm use`)
|
|
601
|
-
.append(`pwd`)
|
|
602
609
|
.append(`npm run start`)
|
|
603
610
|
.execute();
|
|
604
|
-
projectScreen.updateOrCreatePackage(pkg.name, '
|
|
611
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Died');
|
|
605
612
|
}
|
|
606
613
|
};
|
|
607
614
|
exports.Phase_DeployFrontend = {
|
|
@@ -617,12 +624,13 @@ exports.Phase_DeployFrontend = {
|
|
|
617
624
|
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
618
625
|
if (pkg.type !== 'firebase-hosting-app')
|
|
619
626
|
throw new ts_common_1.BadImplementationException(`Somehow got a non firebase hosting package here: ${(0, ts_common_1.__stringify)(pkg)}`);
|
|
620
|
-
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying
|
|
627
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying');
|
|
628
|
+
const counter = timeCounter();
|
|
621
629
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
622
630
|
.cd(pkg.path)
|
|
623
631
|
.append(`firebase deploy --only hosting`)
|
|
624
632
|
.execute();
|
|
625
|
-
projectScreen.updateOrCreatePackage(pkg.name,
|
|
633
|
+
projectScreen.updateOrCreatePackage(pkg.name, `Deployed (${counter.format('mm:ss.zzz')})`);
|
|
626
634
|
}
|
|
627
635
|
};
|
|
628
636
|
exports.Phase_DeployBackend = {
|
|
@@ -635,11 +643,33 @@ exports.Phase_DeployBackend = {
|
|
|
635
643
|
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
636
644
|
if (pkg.type !== 'firebase-functions-app')
|
|
637
645
|
throw new ts_common_1.BadImplementationException(`Somehow got a non firebase functions package here: ${(0, ts_common_1.__stringify)(pkg)}`);
|
|
638
|
-
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying
|
|
646
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying...');
|
|
647
|
+
const counter = timeCounter();
|
|
639
648
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
640
649
|
.cd(pkg.path)
|
|
641
650
|
.append(`firebase --debug deploy --only functions --force`)
|
|
642
651
|
.execute();
|
|
643
|
-
projectScreen.updateOrCreatePackage(pkg.name,
|
|
652
|
+
projectScreen.updateOrCreatePackage(pkg.name, `Deployed (${counter.format('mm:ss.zzz')})`);
|
|
644
653
|
}
|
|
645
654
|
};
|
|
655
|
+
function timeCounter() {
|
|
656
|
+
const started = (0, ts_common_1.currentTimeMillis)();
|
|
657
|
+
return {
|
|
658
|
+
dt: () => (0, ts_common_1.currentTimeMillis)() - started,
|
|
659
|
+
format: (format) => {
|
|
660
|
+
let dt = (0, ts_common_1.currentTimeMillis)() - started;
|
|
661
|
+
const hours = Math.floor(dt / ts_common_1.Hour);
|
|
662
|
+
dt -= hours * ts_common_1.Hour;
|
|
663
|
+
const minutes = Math.floor(dt / ts_common_1.Minute);
|
|
664
|
+
dt -= minutes * ts_common_1.Minute;
|
|
665
|
+
const seconds = Math.floor(dt / ts_common_1.Second);
|
|
666
|
+
dt -= seconds * ts_common_1.Second;
|
|
667
|
+
const millis = dt;
|
|
668
|
+
return format
|
|
669
|
+
.replace('hh', String(hours).padStart(2, '0'))
|
|
670
|
+
.replace('mm', String(minutes).padStart(2, '0'))
|
|
671
|
+
.replace('ss', String(seconds).padStart(2, '0'))
|
|
672
|
+
.replace('zzz', String(millis).padStart(3, '0'));
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}
|