@nu-art/build-and-install 0.204.0 → 0.204.2
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/build-and-install.js +7 -14
- package/core/consts.d.ts +3 -0
- package/core/consts.js +3 -1
- package/core/package/consts.d.ts +0 -1
- package/core/package/consts.js +1 -7
- package/core/params/params.d.ts +4 -20
- package/core/params/params.js +18 -146
- package/defaults/consts.d.ts +35 -0
- package/defaults/consts.js +34 -0
- package/logic/ProjectManager.d.ts +11 -5
- package/logic/ProjectManager.js +99 -12
- package/package.json +3 -3
- package/phases/phases.d.ts +2 -1
- package/phases/phases.js +143 -63
- package/project-manager.d.ts +4 -0
- package/project-manager.js +9 -0
package/build-and-install.js
CHANGED
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ProjectManager_1 = require("./logic/ProjectManager");
|
|
4
4
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
5
|
const phases_1 = require("./phases/phases");
|
|
6
|
-
const
|
|
6
|
+
const params_1 = require("./core/params/params");
|
|
7
|
+
ts_common_1.DebugFlag.DefaultLogLevel = params_1.RuntimeParams.debug ? ts_common_1.LogLevel.Debug : ts_common_1.LogLevel.Info;
|
|
8
|
+
const projectManager = new ProjectManager_1.ProjectManager();
|
|
7
9
|
projectManager.registerPhase(phases_1.Phase_PrintHelp);
|
|
8
10
|
projectManager.registerPhase(phases_1.Phase_SetWithThunderstorm);
|
|
9
11
|
projectManager.registerPhase(phases_1.Phase_SetupProject);
|
|
12
|
+
projectManager.registerPhase(phases_1.Phase_PrepareParams);
|
|
10
13
|
projectManager.registerPhase(phases_1.Phase_ResolveTemplate);
|
|
11
14
|
projectManager.registerPhase(phases_1.Phase_ResolveEnv);
|
|
12
15
|
projectManager.registerPhase(phases_1.Phase_ResolvePackages);
|
|
@@ -15,28 +18,18 @@ projectManager.registerPhase(phases_1.Phase_PrintDependencyTree);
|
|
|
15
18
|
projectManager.registerPhase(phases_1.Phase_CheckCyclicImports);
|
|
16
19
|
projectManager.registerPhase(phases_1.Phase_PrintEnv);
|
|
17
20
|
projectManager.registerPhase(phases_1.Phase_PackagePurge);
|
|
21
|
+
projectManager.registerPhase(phases_1.Phase_Clean);
|
|
18
22
|
projectManager.registerPhase(phases_1.Phase_InstallGlobals);
|
|
19
23
|
projectManager.registerPhase(phases_1.Phase_InstallPnpm);
|
|
20
24
|
projectManager.registerPhase(phases_1.Phase_InstallPackages);
|
|
21
|
-
projectManager.registerPhase(phases_1.Phase_Clean);
|
|
22
25
|
projectManager.registerPhase(phases_1.Phase_Lint);
|
|
26
|
+
projectManager.registerPhase(phases_1.Phase_PrepareWatch);
|
|
23
27
|
projectManager.registerPhase(phases_1.Phase_Compile);
|
|
24
28
|
projectManager.registerPhase(phases_1.Phase_CompileWatch);
|
|
25
29
|
projectManager.registerPhase(phases_1.Phase_Launch);
|
|
26
30
|
projectManager.registerPhase(phases_1.Phase_DeployFrontend);
|
|
27
31
|
projectManager.registerPhase(phases_1.Phase_DeployBackend);
|
|
28
32
|
// projectManager.registerPhase(Phase_Debug);
|
|
29
|
-
(
|
|
30
|
-
return projectManager.execute();
|
|
31
|
-
// await projectManager.runPhaseByKey('with-ts-home');
|
|
32
|
-
// await projectManager.runPhaseByKey('setup-project');
|
|
33
|
-
// await projectManager.runPhaseByKey('resolve-template');
|
|
34
|
-
// await projectManager.runPhaseByKey('debug');
|
|
35
|
-
// await projectManager.runPhaseByKey('resolve-env');
|
|
36
|
-
// await projectManager.runPhaseByKey('firebase-function-test');
|
|
37
|
-
// await projectManager.runPhaseByKey('install');
|
|
38
|
-
// return projectManager.runPhaseByKey('launch');
|
|
39
|
-
// return projectManager.runPhaseByKey('print-dependency-tree');
|
|
40
|
-
})()
|
|
33
|
+
projectManager.execute()
|
|
41
34
|
.then(() => ts_common_1.StaticLogger.logInfo('completed'))
|
|
42
35
|
.catch(err => ts_common_1.StaticLogger.logError('Failed with error: ', err));
|
package/core/consts.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { MemKey } from '@nu-art/ts-common/mem-storage/MemStorage';
|
|
2
|
+
import { RuntimeProjectConfig } from './types';
|
|
1
3
|
export declare const CONST_PackageJSONTemplate = "__package.json";
|
|
2
4
|
export declare const CONST_PackageJSON = "package.json";
|
|
3
5
|
export declare const CONST_FirebaseRC = ".firebaserc";
|
|
4
6
|
export declare const CONST_FirebaseJSON = "firebase.json";
|
|
7
|
+
export declare const MemKey_Packages: MemKey<RuntimeProjectConfig>;
|
package/core/consts.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONST_FirebaseJSON = exports.CONST_FirebaseRC = exports.CONST_PackageJSON = exports.CONST_PackageJSONTemplate = void 0;
|
|
3
|
+
exports.MemKey_Packages = exports.CONST_FirebaseJSON = exports.CONST_FirebaseRC = exports.CONST_PackageJSON = exports.CONST_PackageJSONTemplate = void 0;
|
|
4
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
4
5
|
exports.CONST_PackageJSONTemplate = '__package.json';
|
|
5
6
|
exports.CONST_PackageJSON = 'package.json';
|
|
6
7
|
exports.CONST_FirebaseRC = '.firebaserc';
|
|
7
8
|
exports.CONST_FirebaseJSON = 'firebase.json';
|
|
9
|
+
exports.MemKey_Packages = new MemStorage_1.MemKey('bai-packages', true);
|
package/core/package/consts.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FirebasePackageConfig } from '../types';
|
|
2
2
|
export type DefaultType_ProjectEnvs = 'local' | 'dev' | 'staging' | 'prod';
|
|
3
3
|
export declare const Default_FunctionsIgnoreFiles: string[];
|
|
4
|
-
export declare const Default_ListOfFirebaseConfigFiles: string[];
|
|
5
4
|
export declare const Default_HostingConfig: {
|
|
6
5
|
public: string;
|
|
7
6
|
rewrites: {
|
package/core/package/consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Default_FirebaseProjectConfig = exports.Default_HostingConfig = exports.
|
|
3
|
+
exports.Default_FirebaseProjectConfig = exports.Default_HostingConfig = exports.Default_FunctionsIgnoreFiles = void 0;
|
|
4
4
|
const EnvName_local = 'local';
|
|
5
5
|
const EnvName_dev = 'dev';
|
|
6
6
|
const EnvName_staging = 'staging';
|
|
@@ -25,12 +25,6 @@ exports.Default_FunctionsIgnoreFiles = [
|
|
|
25
25
|
'firestore-debug.log',
|
|
26
26
|
'firebase-debug.log'
|
|
27
27
|
];
|
|
28
|
-
exports.Default_ListOfFirebaseConfigFiles = [
|
|
29
|
-
'database.rules.json',
|
|
30
|
-
'firestore.indexes.json',
|
|
31
|
-
'firestore.rules',
|
|
32
|
-
'storage.rules',
|
|
33
|
-
];
|
|
34
28
|
exports.Default_HostingConfig = {
|
|
35
29
|
public: 'dist',
|
|
36
30
|
rewrites: [
|
package/core/params/params.d.ts
CHANGED
|
@@ -3,49 +3,33 @@ export declare const BaiParam_Help: BaseCliParam<'help', boolean>;
|
|
|
3
3
|
export declare const BaiParam_DependencyTree: BaseCliParam<'dependencyTree', boolean>;
|
|
4
4
|
export declare const BaiParam_CheckCyclicImports: BaseCliParam<'checkCyclicImports', boolean>;
|
|
5
5
|
export declare const BaiParam_PrintEnv: BaseCliParam<'printEnv', boolean>;
|
|
6
|
-
export declare const BaiParam_Purge: BaseCliParam<'purge', boolean>;
|
|
7
|
-
export declare const BaiParam_Clean: BaseCliParam<'clean', boolean>;
|
|
8
6
|
export declare const BaiParam_continue: BaseCliParam<'continue', boolean>;
|
|
9
|
-
export declare const BaiParam_UsePackage: BaseCliParam<'usePackage', string>;
|
|
10
|
-
export declare const BaiParam_ProjectLibs: BaseCliParam<'projectLibs', boolean>;
|
|
11
7
|
export declare const BaiParam_SetEnv: BaseCliParam<'setEnv', string>;
|
|
12
|
-
export declare const BaiParam_FallbackEnv: BaseCliParam<'fallbackEnv', string>;
|
|
13
8
|
export declare const BaiParam_Setup: BaseCliParam<'setup', boolean>;
|
|
14
9
|
export declare const BaiParam_Install: BaseCliParam<'install', boolean>;
|
|
15
10
|
export declare const BaiParam_InstallPackages: BaseCliParam<'installPackages', boolean>;
|
|
16
11
|
export declare const BaiParam_InstallGlobals: BaseCliParam<'installGlobals', boolean>;
|
|
12
|
+
export declare const BaiParam_Clean: BaseCliParam<'clean', boolean>;
|
|
13
|
+
export declare const BaiParam_Purge: BaseCliParam<'purge', boolean>;
|
|
17
14
|
export declare const BaiParam_Generate: BaseCliParam<'generate', boolean>;
|
|
18
|
-
export declare const BaiParam_CleanEnv: BaseCliParam<'cleanEnv', boolean>;
|
|
19
|
-
export declare const BaiParam_Link: BaseCliParam<'link', boolean>;
|
|
20
15
|
export declare const BaiParam_GenerateDocs: BaseCliParam<'generateDocs', boolean>;
|
|
21
|
-
export declare const BaiParam_LinkOnly: BaseCliParam<'linkOnly', boolean>;
|
|
22
16
|
export declare const BaiParam_NoBuild: BaseCliParam<'noBuild', boolean>;
|
|
23
17
|
export declare const BaiParam_DryRun: BaseCliParam<'dryRun', boolean>;
|
|
24
18
|
export declare const BaiParam_ThunderstormHome: BaseCliParam<'thunderstormHome', boolean>;
|
|
25
19
|
export declare const BaiParam_NoThunderstorm: BaseCliParam<'noThunderstorm', boolean>;
|
|
26
20
|
export declare const BaiParam_Lint: BaseCliParam<'lint', boolean>;
|
|
27
|
-
export declare const BaiParam_OutputDir: BaseCliParam<'outputDir', string>;
|
|
28
|
-
export declare const BaiParam_CheckImports: BaseCliParam<'checkImports', boolean>;
|
|
29
21
|
export declare const BaiParam_Watch: BaseCliParam<'watch', boolean>;
|
|
30
22
|
export declare const BaiParam_Test: BaseCliParam<'test', string>;
|
|
31
|
-
export declare const BaiParam_Account: BaseCliParam<'account', string>;
|
|
32
|
-
export declare const BaiParam_OutputTestDir: BaseCliParam<'outputTestDir', string>;
|
|
33
23
|
export declare const BaiParam_Launch: BaseCliParam<'launch', string>;
|
|
34
|
-
export declare const BaiParam_FileToLaunch: BaseCliParam<'fileToLaunch', string>;
|
|
35
24
|
export declare const BaiParam_LaunchFrontend: BaseCliParam<'launchFrontend', boolean>;
|
|
36
25
|
export declare const BaiParam_LaunchBackend: BaseCliParam<'launchBackend', boolean>;
|
|
37
26
|
export declare const BaiParam_DebugBackend: BaseCliParam<'debugBackend', boolean>;
|
|
38
27
|
export declare const BaiParam_Deploy: BaseCliParam<'deploy', string>;
|
|
39
28
|
export declare const BaiParam_DeployBackend: BaseCliParam<'deployBackend', boolean>;
|
|
40
29
|
export declare const BaiParam_DeployFrontend: BaseCliParam<'deployFrontend', boolean>;
|
|
41
|
-
export declare const BaiParam_SetVersion: BaseCliParam<'setVersion', string>;
|
|
42
30
|
export declare const BaiParam_NoGit: BaseCliParam<'noGit', boolean>;
|
|
43
|
-
export declare const BaiParam_DebugTranspiler: BaseCliParam<'debugTranspiler', boolean>;
|
|
44
31
|
export declare const BaiParam_Debug: BaseCliParam<'debug', boolean>;
|
|
45
|
-
export declare const BaiParam_Debugger: BaseCliParam<'debugger', boolean>;
|
|
46
|
-
export declare const BaiParam_Log: BaseCliParam<'setLogLevel', string>;
|
|
47
32
|
export declare const BaiParam_QuickDeploy: BaseCliParam<'quickDeploy', boolean>;
|
|
48
33
|
export declare const BaiParam_Publish: BaseCliParam<'publish', string>;
|
|
49
|
-
export declare const
|
|
50
|
-
export declare const
|
|
51
|
-
export declare const RuntimeParams: import("@nu-art/commando/cli/cli-params").CliParams<(BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"usePackage", string> | BaseCliParam<"projectLibs", boolean> | BaseCliParam<"setEnv", string> | BaseCliParam<"fallbackEnv", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"cleanEnv", boolean> | BaseCliParam<"link", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"linkOnly", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"thunderstormHome", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"outputDir", string> | BaseCliParam<"checkImports", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"account", string> | BaseCliParam<"outputTestDir", string> | BaseCliParam<"launch", string> | BaseCliParam<"fileToLaunch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", boolean> | BaseCliParam<"deployFrontend", boolean> | BaseCliParam<"setVersion", string> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debugTranspiler", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugger", boolean> | BaseCliParam<"setLogLevel", string> | BaseCliParam<"quickDeploy", boolean> | BaseCliParam<"publish", string> | BaseCliParam<"quickPublish", boolean>)[]>;
|
|
34
|
+
export declare const AllBaiParams: (BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"setEnv", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"thunderstormHome", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", boolean> | BaseCliParam<"deployFrontend", boolean> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"quickDeploy", boolean> | BaseCliParam<"publish", string>)[];
|
|
35
|
+
export declare const RuntimeParams: import("@nu-art/commando/cli/cli-params").CliParams<(BaseCliParam<"help", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"printEnv", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"setEnv", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"installPackages", boolean> | BaseCliParam<"installGlobals", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"thunderstormHome", boolean> | BaseCliParam<"noThunderstorm", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"test", string> | BaseCliParam<"launch", string> | BaseCliParam<"launchFrontend", boolean> | BaseCliParam<"launchBackend", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"deployBackend", boolean> | BaseCliParam<"deployFrontend", boolean> | BaseCliParam<"noGit", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"quickDeploy", boolean> | BaseCliParam<"publish", string>)[]>;
|
package/core/params/params.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuntimeParams = exports.AllBaiParams = exports.
|
|
3
|
+
exports.RuntimeParams = exports.AllBaiParams = exports.BaiParam_Publish = exports.BaiParam_QuickDeploy = exports.BaiParam_Debug = exports.BaiParam_NoGit = exports.BaiParam_DeployFrontend = exports.BaiParam_DeployBackend = exports.BaiParam_Deploy = exports.BaiParam_DebugBackend = exports.BaiParam_LaunchBackend = exports.BaiParam_LaunchFrontend = exports.BaiParam_Launch = exports.BaiParam_Test = exports.BaiParam_Watch = exports.BaiParam_Lint = exports.BaiParam_NoThunderstorm = exports.BaiParam_ThunderstormHome = exports.BaiParam_DryRun = exports.BaiParam_NoBuild = exports.BaiParam_GenerateDocs = exports.BaiParam_Generate = exports.BaiParam_Purge = exports.BaiParam_Clean = exports.BaiParam_InstallGlobals = exports.BaiParam_InstallPackages = exports.BaiParam_Install = exports.BaiParam_Setup = exports.BaiParam_SetEnv = exports.BaiParam_continue = exports.BaiParam_PrintEnv = exports.BaiParam_CheckCyclicImports = exports.BaiParam_DependencyTree = exports.BaiParam_Help = void 0;
|
|
4
4
|
const cli_params_1 = require("@nu-art/commando/cli/cli-params");
|
|
5
5
|
exports.BaiParam_Help = {
|
|
6
6
|
keys: ['--help', '-h'],
|
|
@@ -30,20 +30,6 @@ exports.BaiParam_PrintEnv = {
|
|
|
30
30
|
group: 'General',
|
|
31
31
|
description: 'Will print the current versions of the important tools'
|
|
32
32
|
};
|
|
33
|
-
exports.BaiParam_Purge = {
|
|
34
|
-
keys: ['--purge', '-p'],
|
|
35
|
-
keyName: 'purge',
|
|
36
|
-
group: 'Clean',
|
|
37
|
-
type: 'boolean',
|
|
38
|
-
description: 'Will delete the node_modules folder in all project packages \nWill perform --clean --install'
|
|
39
|
-
};
|
|
40
|
-
exports.BaiParam_Clean = {
|
|
41
|
-
keys: ['--clean', '-c'],
|
|
42
|
-
keyName: 'clean',
|
|
43
|
-
type: 'boolean',
|
|
44
|
-
group: 'Clean',
|
|
45
|
-
description: 'Will delete the output(dist) & test output(dist-test) folders in all project packages'
|
|
46
|
-
};
|
|
47
33
|
exports.BaiParam_continue = {
|
|
48
34
|
keys: ['--continue', '-con'],
|
|
49
35
|
keyName: 'continue',
|
|
@@ -51,20 +37,6 @@ exports.BaiParam_continue = {
|
|
|
51
37
|
group: 'Build',
|
|
52
38
|
description: 'Will pick up where last build process failed'
|
|
53
39
|
};
|
|
54
|
-
exports.BaiParam_UsePackage = {
|
|
55
|
-
keys: ['--use-package', '-up'],
|
|
56
|
-
keyName: 'usePackage',
|
|
57
|
-
type: 'string',
|
|
58
|
-
group: 'Build',
|
|
59
|
-
description: 'Would ONLY run the script in the context of the specified project packages \nvalue required: project-package-folder(string)'
|
|
60
|
-
};
|
|
61
|
-
exports.BaiParam_ProjectLibs = {
|
|
62
|
-
keys: ['--project-libs', '-pl'],
|
|
63
|
-
keyName: 'projectLibs',
|
|
64
|
-
type: 'boolean',
|
|
65
|
-
group: 'Build',
|
|
66
|
-
description: 'Would ONLY run the script in the context of the project libs'
|
|
67
|
-
};
|
|
68
40
|
exports.BaiParam_SetEnv = {
|
|
69
41
|
keys: ['--set-env', '-se'],
|
|
70
42
|
keyName: 'setEnv',
|
|
@@ -73,13 +45,6 @@ exports.BaiParam_SetEnv = {
|
|
|
73
45
|
defaultValue: 'local',
|
|
74
46
|
description: 'Will set the .config-${environment}.json as the current .config.json and prepare it as base 64 for local usage \ninput required: envName(string)'
|
|
75
47
|
};
|
|
76
|
-
exports.BaiParam_FallbackEnv = {
|
|
77
|
-
keys: ['--fallback-env', '-fe'],
|
|
78
|
-
keyName: 'fallbackEnv',
|
|
79
|
-
type: 'string',
|
|
80
|
-
group: 'Build',
|
|
81
|
-
description: 'When setting env some of the files might be missing and would fallback to the provided env \ninput required: envName(string)'
|
|
82
|
-
};
|
|
83
48
|
exports.BaiParam_Setup = {
|
|
84
49
|
keys: ['--setup', '-s'],
|
|
85
50
|
keyName: 'setup',
|
|
@@ -108,26 +73,27 @@ exports.BaiParam_InstallGlobals = {
|
|
|
108
73
|
group: 'Build',
|
|
109
74
|
description: 'Will install all global packages'
|
|
110
75
|
};
|
|
111
|
-
exports.
|
|
112
|
-
keys: ['--
|
|
113
|
-
keyName: '
|
|
76
|
+
exports.BaiParam_Clean = {
|
|
77
|
+
keys: ['--clean', '-c'],
|
|
78
|
+
keyName: 'clean',
|
|
114
79
|
type: 'boolean',
|
|
115
|
-
group: '
|
|
116
|
-
description: 'Will
|
|
80
|
+
group: 'Clean',
|
|
81
|
+
description: 'Will delete the output(dist) & test output(dist-test) folders in all project packages'
|
|
117
82
|
};
|
|
118
|
-
exports.
|
|
119
|
-
keys: ['--
|
|
120
|
-
|
|
83
|
+
exports.BaiParam_Purge = {
|
|
84
|
+
keys: ['--purge', '-p'],
|
|
85
|
+
dependencies: [{ param: exports.BaiParam_Clean, value: true }, { param: exports.BaiParam_InstallPackages, value: true }],
|
|
86
|
+
keyName: 'purge',
|
|
87
|
+
group: 'Clean',
|
|
121
88
|
type: 'boolean',
|
|
122
|
-
|
|
123
|
-
description: 'will clean env'
|
|
89
|
+
description: 'Will delete the node_modules folder in all project packages \nWill perform --clean --install'
|
|
124
90
|
};
|
|
125
|
-
exports.
|
|
126
|
-
keys: ['--
|
|
127
|
-
keyName: '
|
|
91
|
+
exports.BaiParam_Generate = {
|
|
92
|
+
keys: ['--generate', '-g'],
|
|
93
|
+
keyName: 'generate',
|
|
128
94
|
type: 'boolean',
|
|
129
95
|
group: 'Build',
|
|
130
|
-
description: '
|
|
96
|
+
description: 'Will generate sources in the apps if needed'
|
|
131
97
|
};
|
|
132
98
|
exports.BaiParam_GenerateDocs = {
|
|
133
99
|
keys: ['--generate-docs', '-docs'],
|
|
@@ -136,13 +102,6 @@ exports.BaiParam_GenerateDocs = {
|
|
|
136
102
|
group: 'Build',
|
|
137
103
|
description: 'Would generate ts-docs documentation'
|
|
138
104
|
};
|
|
139
|
-
exports.BaiParam_LinkOnly = {
|
|
140
|
-
keys: ['--linkOnly', '-lo'],
|
|
141
|
-
keyName: 'linkOnly',
|
|
142
|
-
group: 'Build',
|
|
143
|
-
type: 'boolean',
|
|
144
|
-
description: 'Would ONLY link dependencies between project packages'
|
|
145
|
-
};
|
|
146
105
|
exports.BaiParam_NoBuild = {
|
|
147
106
|
keys: ['--no-build', '-nb'],
|
|
148
107
|
keyName: 'noBuild',
|
|
@@ -151,7 +110,7 @@ exports.BaiParam_NoBuild = {
|
|
|
151
110
|
description: 'Skip the build and link steps'
|
|
152
111
|
};
|
|
153
112
|
exports.BaiParam_DryRun = {
|
|
154
|
-
keys: ['--dry-run', '-dry'],
|
|
113
|
+
keys: ['--dry-run', '-dry', '--dryrun'],
|
|
155
114
|
keyName: 'dryRun',
|
|
156
115
|
group: 'Other',
|
|
157
116
|
type: 'boolean',
|
|
@@ -178,20 +137,6 @@ exports.BaiParam_Lint = {
|
|
|
178
137
|
group: 'Build',
|
|
179
138
|
description: 'Run lint on all the project packages'
|
|
180
139
|
};
|
|
181
|
-
exports.BaiParam_OutputDir = {
|
|
182
|
-
keys: ['--output-dir', '-od'],
|
|
183
|
-
keyName: 'outputDir',
|
|
184
|
-
type: 'string',
|
|
185
|
-
group: 'Build',
|
|
186
|
-
description: 'Set the output dir name/path (default: dist) \nrequired input: path-to-output-folder (string)'
|
|
187
|
-
};
|
|
188
|
-
exports.BaiParam_CheckImports = {
|
|
189
|
-
keys: ['--check-imports', '-ci'],
|
|
190
|
-
keyName: 'checkImports',
|
|
191
|
-
type: 'boolean',
|
|
192
|
-
group: 'Build',
|
|
193
|
-
description: 'Will check for circular import in files...'
|
|
194
|
-
};
|
|
195
140
|
exports.BaiParam_Watch = {
|
|
196
141
|
keys: ['--watch', '-w'],
|
|
197
142
|
keyName: 'watch',
|
|
@@ -207,20 +152,6 @@ exports.BaiParam_Test = {
|
|
|
207
152
|
description: 'Run the tests in all the project packages\naccepts test label to run optionally. default will be empty string',
|
|
208
153
|
defaultValue: '.*'
|
|
209
154
|
};
|
|
210
|
-
exports.BaiParam_Account = {
|
|
211
|
-
keys: ['--account', '-a'],
|
|
212
|
-
keyName: 'account',
|
|
213
|
-
type: 'string',
|
|
214
|
-
group: 'Test',
|
|
215
|
-
description: 'Run the tests in all the project packages \ninput required, path to firebase service account (string'
|
|
216
|
-
};
|
|
217
|
-
exports.BaiParam_OutputTestDir = {
|
|
218
|
-
keys: ['--output-test-dir', '-otd'],
|
|
219
|
-
keyName: 'outputTestDir',
|
|
220
|
-
type: 'string',
|
|
221
|
-
group: 'Test',
|
|
222
|
-
description: 'Set the tests output dir name/path (default: dist-test) \ninput optional path to output folder'
|
|
223
|
-
};
|
|
224
155
|
exports.BaiParam_Launch = {
|
|
225
156
|
keys: ['--launch', '-l'],
|
|
226
157
|
keyName: 'launch',
|
|
@@ -229,13 +160,6 @@ exports.BaiParam_Launch = {
|
|
|
229
160
|
process: () => '.*',
|
|
230
161
|
description: 'It will add the provided App to the launch list \nrequired input: path-to-app-to-launch(string)'
|
|
231
162
|
};
|
|
232
|
-
exports.BaiParam_FileToLaunch = {
|
|
233
|
-
keys: ['--file', '-f'],
|
|
234
|
-
keyName: 'fileToLaunch',
|
|
235
|
-
group: 'Apps',
|
|
236
|
-
type: 'string',
|
|
237
|
-
description: 'The file name to launch \ninput required: path-to-file(string)'
|
|
238
|
-
};
|
|
239
163
|
exports.BaiParam_LaunchFrontend = {
|
|
240
164
|
keys: ['--launch-frontend', '-lf'],
|
|
241
165
|
keyName: 'launchFrontend',
|
|
@@ -279,13 +203,6 @@ exports.BaiParam_DeployFrontend = {
|
|
|
279
203
|
group: 'Apps',
|
|
280
204
|
description: 'Will add the app frontend to the deploy list'
|
|
281
205
|
};
|
|
282
|
-
exports.BaiParam_SetVersion = {
|
|
283
|
-
keys: ['--set-version', '-sv'],
|
|
284
|
-
keyName: 'setVersion',
|
|
285
|
-
type: 'string',
|
|
286
|
-
group: 'Apps',
|
|
287
|
-
description: 'Set application version before deploy \ninput required: in the following structure: x.y.z (string)'
|
|
288
|
-
};
|
|
289
206
|
exports.BaiParam_NoGit = {
|
|
290
207
|
keys: ['--no-git'],
|
|
291
208
|
keyName: 'noGit',
|
|
@@ -293,13 +210,6 @@ exports.BaiParam_NoGit = {
|
|
|
293
210
|
group: 'Other',
|
|
294
211
|
description: '',
|
|
295
212
|
};
|
|
296
|
-
exports.BaiParam_DebugTranspiler = {
|
|
297
|
-
keys: ['--debug-transpiler', '-dt'],
|
|
298
|
-
keyName: 'debugTranspiler',
|
|
299
|
-
type: 'boolean',
|
|
300
|
-
group: 'Other',
|
|
301
|
-
description: ''
|
|
302
|
-
};
|
|
303
213
|
exports.BaiParam_Debug = {
|
|
304
214
|
keys: ['--debug'],
|
|
305
215
|
keyName: 'debug',
|
|
@@ -307,21 +217,6 @@ exports.BaiParam_Debug = {
|
|
|
307
217
|
type: 'boolean',
|
|
308
218
|
description: 'Will print the parameters the script is running with'
|
|
309
219
|
};
|
|
310
|
-
exports.BaiParam_Debugger = {
|
|
311
|
-
keys: ['--debugger'],
|
|
312
|
-
keyName: 'debugger',
|
|
313
|
-
group: 'Other',
|
|
314
|
-
type: 'boolean',
|
|
315
|
-
description: 'Will stop at break points'
|
|
316
|
-
};
|
|
317
|
-
exports.BaiParam_Log = {
|
|
318
|
-
keys: ['--log'],
|
|
319
|
-
keyName: 'setLogLevel',
|
|
320
|
-
group: 'Other',
|
|
321
|
-
type: 'string',
|
|
322
|
-
options: ['verbose', 'debug', 'info', 'warning', 'error'],
|
|
323
|
-
description: 'Set the script log level \nEnum options: verbose | debug | info | warning | error \ndefault level: info'
|
|
324
|
-
};
|
|
325
220
|
exports.BaiParam_QuickDeploy = {
|
|
326
221
|
keys: ['--quick-deploy', '-qd'],
|
|
327
222
|
keyName: 'quickDeploy',
|
|
@@ -337,13 +232,6 @@ exports.BaiParam_Publish = {
|
|
|
337
232
|
description: 'Will publish thunderstorm && promote thunderstorm version \nenum options: patch | minor | major \nDefault Param: patch',
|
|
338
233
|
defaultValue: 'patch'
|
|
339
234
|
};
|
|
340
|
-
exports.BaiParam_QuickPublish = {
|
|
341
|
-
keys: ['--quick-publish', '-qp'],
|
|
342
|
-
keyName: 'quickPublish',
|
|
343
|
-
type: 'boolean',
|
|
344
|
-
group: 'Other',
|
|
345
|
-
description: 'Will publish thunderstorm without link clean lint and compile',
|
|
346
|
-
};
|
|
347
235
|
exports.AllBaiParams = [
|
|
348
236
|
exports.BaiParam_Help,
|
|
349
237
|
exports.BaiParam_DependencyTree,
|
|
@@ -352,46 +240,30 @@ exports.AllBaiParams = [
|
|
|
352
240
|
exports.BaiParam_Purge,
|
|
353
241
|
exports.BaiParam_Clean,
|
|
354
242
|
exports.BaiParam_continue,
|
|
355
|
-
exports.BaiParam_UsePackage,
|
|
356
|
-
exports.BaiParam_ProjectLibs,
|
|
357
243
|
exports.BaiParam_SetEnv,
|
|
358
|
-
exports.BaiParam_FallbackEnv,
|
|
359
244
|
exports.BaiParam_Setup,
|
|
360
245
|
exports.BaiParam_Install,
|
|
361
246
|
exports.BaiParam_InstallPackages,
|
|
362
247
|
exports.BaiParam_InstallGlobals,
|
|
363
248
|
exports.BaiParam_Generate,
|
|
364
|
-
exports.BaiParam_CleanEnv,
|
|
365
|
-
exports.BaiParam_Link,
|
|
366
249
|
exports.BaiParam_GenerateDocs,
|
|
367
|
-
exports.BaiParam_LinkOnly,
|
|
368
250
|
exports.BaiParam_NoBuild,
|
|
369
251
|
exports.BaiParam_DryRun,
|
|
370
252
|
exports.BaiParam_ThunderstormHome,
|
|
371
253
|
exports.BaiParam_NoThunderstorm,
|
|
372
254
|
exports.BaiParam_Lint,
|
|
373
|
-
exports.BaiParam_OutputDir,
|
|
374
|
-
exports.BaiParam_CheckImports,
|
|
375
255
|
exports.BaiParam_Watch,
|
|
376
256
|
exports.BaiParam_Test,
|
|
377
|
-
exports.BaiParam_Account,
|
|
378
|
-
exports.BaiParam_OutputTestDir,
|
|
379
257
|
exports.BaiParam_Launch,
|
|
380
|
-
exports.BaiParam_FileToLaunch,
|
|
381
258
|
exports.BaiParam_LaunchFrontend,
|
|
382
259
|
exports.BaiParam_LaunchBackend,
|
|
383
260
|
exports.BaiParam_DebugBackend,
|
|
384
261
|
exports.BaiParam_Deploy,
|
|
385
262
|
exports.BaiParam_DeployBackend,
|
|
386
263
|
exports.BaiParam_DeployFrontend,
|
|
387
|
-
exports.BaiParam_SetVersion,
|
|
388
264
|
exports.BaiParam_NoGit,
|
|
389
|
-
exports.BaiParam_DebugTranspiler,
|
|
390
265
|
exports.BaiParam_Debug,
|
|
391
|
-
exports.BaiParam_Debugger,
|
|
392
|
-
exports.BaiParam_Log,
|
|
393
266
|
exports.BaiParam_QuickDeploy,
|
|
394
|
-
exports.BaiParam_Publish,
|
|
395
|
-
exports.BaiParam_QuickPublish,
|
|
267
|
+
exports.BaiParam_Publish, // TODO: to implement
|
|
396
268
|
];
|
|
397
269
|
exports.RuntimeParams = cli_params_1.CLIParams_Resolver.create(...exports.AllBaiParams).resolveParamValue();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MemKey } from '@nu-art/ts-common/mem-storage/MemStorage';
|
|
2
|
+
export declare const Const_FirebaseDefaultsKeyToFile: {
|
|
3
|
+
[k in keyof typeof Default_Files['firebaseConfig']]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const Default_Files: {
|
|
6
|
+
firebaseConfig: {
|
|
7
|
+
databaseRules: string;
|
|
8
|
+
firestoreIndexesRules: string;
|
|
9
|
+
firestoreRules: string;
|
|
10
|
+
storageRules: string;
|
|
11
|
+
};
|
|
12
|
+
backend: {
|
|
13
|
+
proxy: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const Const_FirebaseConfigKeys: (keyof typeof Default_Files['firebaseConfig'])[];
|
|
17
|
+
export declare const Default_OutputFiles: {
|
|
18
|
+
runningStatus: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const MemKey_DefaultFiles: MemKey<{
|
|
21
|
+
firebaseConfig: {
|
|
22
|
+
databaseRules: string;
|
|
23
|
+
firestoreIndexesRules: string;
|
|
24
|
+
firestoreRules: string;
|
|
25
|
+
storageRules: string;
|
|
26
|
+
};
|
|
27
|
+
backend: {
|
|
28
|
+
proxy: string;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
export type RunningStatus = {
|
|
32
|
+
phaseKey: string;
|
|
33
|
+
packageDependencyIndex?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const MemKey_RunningStatus: MemKey<RunningStatus>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemKey_RunningStatus = exports.MemKey_DefaultFiles = exports.Default_OutputFiles = exports.Const_FirebaseConfigKeys = exports.Default_Files = exports.Const_FirebaseDefaultsKeyToFile = void 0;
|
|
4
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
5
|
+
const CONST_FirebaseConfig = `${__dirname}/.firebase_config`;
|
|
6
|
+
const CONST_BackendProxy = `${__dirname}/backend-proxy`;
|
|
7
|
+
exports.Const_FirebaseDefaultsKeyToFile = {
|
|
8
|
+
databaseRules: 'database.rules.json',
|
|
9
|
+
firestoreIndexesRules: 'firestore.indexes.json',
|
|
10
|
+
firestoreRules: 'firestore.rules',
|
|
11
|
+
storageRules: 'storage.rules',
|
|
12
|
+
};
|
|
13
|
+
exports.Default_Files = {
|
|
14
|
+
firebaseConfig: {
|
|
15
|
+
databaseRules: `${CONST_FirebaseConfig}/database.rules.json`,
|
|
16
|
+
firestoreIndexesRules: `${CONST_FirebaseConfig}/firestore.indexes.json`,
|
|
17
|
+
firestoreRules: `${CONST_FirebaseConfig}/firestore.rules`,
|
|
18
|
+
storageRules: `${CONST_FirebaseConfig}/storage.rules`,
|
|
19
|
+
},
|
|
20
|
+
backend: {
|
|
21
|
+
proxy: `${CONST_BackendProxy}/proxy._ts`
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.Const_FirebaseConfigKeys = [
|
|
25
|
+
'databaseRules',
|
|
26
|
+
'firestoreIndexesRules',
|
|
27
|
+
'firestoreRules',
|
|
28
|
+
'storageRules',
|
|
29
|
+
];
|
|
30
|
+
exports.Default_OutputFiles = {
|
|
31
|
+
runningStatus: './.trash/running-status.json'
|
|
32
|
+
};
|
|
33
|
+
exports.MemKey_DefaultFiles = new MemStorage_1.MemKey('default-files');
|
|
34
|
+
exports.MemKey_RunningStatus = new MemStorage_1.MemKey('running-status');
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RuntimePackage, RuntimePackage_WithOutput } from '../core/types';
|
|
2
2
|
import { Logger } from '@nu-art/ts-common';
|
|
3
|
+
import { RunningStatus } from '../defaults/consts';
|
|
3
4
|
export declare const PackageBuildPhaseType_Package: "package";
|
|
4
5
|
export declare const PackageBuildPhaseType_PackageWithOutput: "package-with-output";
|
|
5
6
|
export declare const PackageBuildPhaseType_Project: "project";
|
|
6
7
|
type BuildPhase_Base = {
|
|
7
8
|
name: string;
|
|
8
9
|
terminatingPhase?: boolean;
|
|
10
|
+
breakAfterPhase?: boolean;
|
|
9
11
|
mandatoryPhases?: BuildPhase[];
|
|
12
|
+
isMandatory?: boolean;
|
|
10
13
|
};
|
|
11
14
|
type BuildPhase_Package = BuildPhase_Base & {
|
|
12
15
|
type: typeof PackageBuildPhaseType_Package;
|
|
@@ -26,13 +29,16 @@ type BuildPhase_Project = BuildPhase_Base & {
|
|
|
26
29
|
export type BuildPhase = BuildPhase_Package | BuildPhase_PackageWithOutput | BuildPhase_Project;
|
|
27
30
|
export declare class ProjectManager extends Logger {
|
|
28
31
|
private phases;
|
|
29
|
-
private config;
|
|
30
32
|
private dryRun;
|
|
31
33
|
private terminate;
|
|
32
|
-
|
|
34
|
+
private prevRunningStatus?;
|
|
35
|
+
constructor();
|
|
36
|
+
private loadPackage;
|
|
33
37
|
registerPhase(phase: BuildPhase): void;
|
|
38
|
+
updateRunningStatus: (runningStatus?: RunningStatus) => Promise<void>;
|
|
34
39
|
prepare(phases?: BuildPhase[], index?: number): Promise<(() => Promise<void>) | undefined>;
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
private static isAborted;
|
|
41
|
+
execute(phases?: BuildPhase[], prevRunningStatus?: RunningStatus, signal?: AbortSignal): Promise<void>;
|
|
42
|
+
executePhase(phaseKey: string, prevRunningStatus?: RunningStatus, signal?: AbortSignal): Promise<void>;
|
|
37
43
|
}
|
|
38
44
|
export {};
|
package/logic/ProjectManager.js
CHANGED
|
@@ -3,6 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProjectManager = exports.PackageBuildPhaseType_Project = exports.PackageBuildPhaseType_PackageWithOutput = exports.PackageBuildPhaseType_Package = void 0;
|
|
4
4
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
5
|
const params_1 = require("../core/params/params");
|
|
6
|
+
const tools_1 = require("@nu-art/commando/core/tools");
|
|
7
|
+
const map_project_packages_1 = require("./map-project-packages");
|
|
8
|
+
const consts_1 = require("../core/consts");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const consts_2 = require("../defaults/consts");
|
|
12
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
13
|
+
const project_manager_1 = require("../project-manager");
|
|
6
14
|
exports.PackageBuildPhaseType_Package = 'package';
|
|
7
15
|
exports.PackageBuildPhaseType_PackageWithOutput = 'package-with-output';
|
|
8
16
|
exports.PackageBuildPhaseType_Project = 'project';
|
|
@@ -17,15 +25,26 @@ function resolveAllMandatoryPhases(phase) {
|
|
|
17
25
|
return (0, ts_common_1.filterDuplicates)(result, result => result.name);
|
|
18
26
|
}
|
|
19
27
|
class ProjectManager extends ts_common_1.Logger {
|
|
20
|
-
constructor(
|
|
28
|
+
constructor() {
|
|
21
29
|
super();
|
|
22
30
|
this.phases = [];
|
|
23
31
|
this.dryRun = params_1.RuntimeParams.dryRun;
|
|
24
32
|
this.terminate = false;
|
|
25
|
-
this.
|
|
33
|
+
this.updateRunningStatus = async (runningStatus = consts_2.MemKey_RunningStatus.get(undefined)) => {
|
|
34
|
+
if (runningStatus)
|
|
35
|
+
return fs_1.promises.writeFile(consts_2.Default_OutputFiles.runningStatus, (0, ts_common_1.__stringify)(runningStatus, true));
|
|
36
|
+
};
|
|
26
37
|
ts_common_1.BeLogged.addClient(ts_common_1.LogClient_Terminal);
|
|
27
38
|
this.setMinLevel(ts_common_1.LogLevel.Verbose);
|
|
28
39
|
}
|
|
40
|
+
loadPackage() {
|
|
41
|
+
const pathToConfig = (0, tools_1.convertToFullPath)('./.config/project-config.ts');
|
|
42
|
+
if (!fs.existsSync(pathToConfig))
|
|
43
|
+
throw new ts_common_1.ImplementationMissingException(`Missing ./.config/project-config.ts file, could not find in path: ${pathToConfig}`);
|
|
44
|
+
const projectConfig = require(pathToConfig).default;
|
|
45
|
+
const packages = (0, map_project_packages_1.mapProjectPackages)(projectConfig);
|
|
46
|
+
consts_1.MemKey_Packages.set(packages);
|
|
47
|
+
}
|
|
29
48
|
registerPhase(phase) {
|
|
30
49
|
this.phases.push(phase);
|
|
31
50
|
}
|
|
@@ -45,7 +64,7 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
45
64
|
}
|
|
46
65
|
if (phase.type !== 'project' || (!phase.filter || await ((_a = phase.filter) === null || _a === void 0 ? void 0 : _a.call(phase))))
|
|
47
66
|
phasesToRun.push(phase);
|
|
48
|
-
if (phasesToRun.length > 0 && phase.terminatingPhase) {
|
|
67
|
+
if ((phasesToRun.length > 0 && phase.terminatingPhase) || phase.breakAfterPhase) {
|
|
49
68
|
i++;
|
|
50
69
|
break;
|
|
51
70
|
}
|
|
@@ -60,9 +79,22 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
60
79
|
return this.logInfo(`Skipping project phases:`, phasesToRun.map(mapToName));
|
|
61
80
|
let didRun = false;
|
|
62
81
|
for (const phase of phasesToRun) {
|
|
82
|
+
if (ProjectManager.isAborted())
|
|
83
|
+
return;
|
|
84
|
+
// if there's a previous running status and the current phase is the one to continue from clean
|
|
85
|
+
if (this.prevRunningStatus && this.prevRunningStatus.phaseKey === phase.name)
|
|
86
|
+
delete this.prevRunningStatus;
|
|
87
|
+
// keep the current running status updated
|
|
88
|
+
if (!this.prevRunningStatus && !phase.terminatingPhase)
|
|
89
|
+
consts_2.MemKey_RunningStatus.set({ phaseKey: phase.name });
|
|
63
90
|
this.logInfo(`Running project phase: ${phase.name}`);
|
|
91
|
+
// if prev running status still exists skip execution
|
|
92
|
+
if (this.prevRunningStatus && !phase.isMandatory) {
|
|
93
|
+
this.logVerbose('Skipping duo continue');
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
64
96
|
if (this.dryRun) {
|
|
65
|
-
await (0, ts_common_1.sleep)(
|
|
97
|
+
await (0, ts_common_1.sleep)(200);
|
|
66
98
|
}
|
|
67
99
|
else
|
|
68
100
|
await phase.action();
|
|
@@ -75,13 +107,22 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
75
107
|
return async () => {
|
|
76
108
|
let didRun = false;
|
|
77
109
|
let didPrintPhase = false;
|
|
78
|
-
const toRunPackages =
|
|
110
|
+
const toRunPackages = consts_1.MemKey_Packages.get().packagesDependency.map((packages, i) => {
|
|
79
111
|
return async () => {
|
|
112
|
+
var _a;
|
|
113
|
+
// if there's a previous running status and the current phase is the one to continue from clean
|
|
114
|
+
if (phasesToRun.find(phase => { var _a; return phase.name === ((_a = this.prevRunningStatus) === null || _a === void 0 ? void 0 : _a.phaseKey); }) && i === ((_a = this.prevRunningStatus) === null || _a === void 0 ? void 0 : _a.packageDependencyIndex))
|
|
115
|
+
delete this.prevRunningStatus;
|
|
80
116
|
let didPrintPackages = false;
|
|
81
117
|
const values = (0, ts_common_1.flatArray)(packages.map(async (pkg) => {
|
|
82
118
|
for (const phase of phasesToRun) {
|
|
119
|
+
if (ProjectManager.isAborted())
|
|
120
|
+
return;
|
|
83
121
|
if (!(!phase.filter || await phase.filter(pkg)))
|
|
84
122
|
continue;
|
|
123
|
+
// keep the current running status updated
|
|
124
|
+
if (!this.prevRunningStatus && !phase.terminatingPhase)
|
|
125
|
+
consts_2.MemKey_RunningStatus.set({ phaseKey: phase.name, packageDependencyIndex: i });
|
|
85
126
|
if (!didPrintPhase) {
|
|
86
127
|
this.logInfo(`Running package phase: ${(0, ts_common_1.__stringify)(phasesToRun.map(mapToName))}`);
|
|
87
128
|
didPrintPhase = true;
|
|
@@ -92,8 +133,13 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
92
133
|
}
|
|
93
134
|
didRun = true;
|
|
94
135
|
this.logDebug(` - ${pkg.name}:${phase.name}`);
|
|
136
|
+
// if prev running status still exists skip execution
|
|
137
|
+
if (this.prevRunningStatus && !phase.isMandatory) {
|
|
138
|
+
this.logVerbose('Skipping duo continue');
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
95
141
|
if (this.dryRun) {
|
|
96
|
-
await (0, ts_common_1.sleep)(
|
|
142
|
+
await (0, ts_common_1.sleep)(200);
|
|
97
143
|
}
|
|
98
144
|
else
|
|
99
145
|
await phase.action(pkg);
|
|
@@ -112,17 +158,58 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
112
158
|
await (nextAction === null || nextAction === void 0 ? void 0 : nextAction());
|
|
113
159
|
};
|
|
114
160
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
161
|
+
static isAborted() {
|
|
162
|
+
try {
|
|
163
|
+
return project_manager_1.MemKey_AbortSignal.get().aborted;
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
118
168
|
}
|
|
119
|
-
async
|
|
120
|
-
|
|
169
|
+
async execute(phases = this.phases, prevRunningStatus, signal) {
|
|
170
|
+
return new MemStorage_1.MemStorage().init(async () => {
|
|
171
|
+
//Update the project manager mem key to be used elsewhere in the project
|
|
172
|
+
project_manager_1.MemKey_ProjectManager.set(this);
|
|
173
|
+
consts_2.MemKey_DefaultFiles.set(consts_2.Default_Files);
|
|
174
|
+
// Set default value to memKey
|
|
175
|
+
consts_2.MemKey_RunningStatus.set({ phaseKey: '' });
|
|
176
|
+
const listener = async (status) => {
|
|
177
|
+
this.logDebug('SIGINT - running status:', status);
|
|
178
|
+
await this.updateRunningStatus();
|
|
179
|
+
process.exit(0);
|
|
180
|
+
};
|
|
181
|
+
process.on('SIGINT', listener);
|
|
182
|
+
try {
|
|
183
|
+
if (params_1.RuntimeParams.continue)
|
|
184
|
+
this.prevRunningStatus = JSON.parse(await fs_1.promises.readFile(consts_2.Default_OutputFiles.runningStatus, { encoding: 'utf-8' }));
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
this.logError('Failed reading running status', e);
|
|
188
|
+
}
|
|
189
|
+
this.loadPackage();
|
|
190
|
+
if (signal)
|
|
191
|
+
project_manager_1.MemKey_AbortSignal.set(signal);
|
|
192
|
+
// update prev running status if passed
|
|
193
|
+
if (prevRunningStatus) {
|
|
194
|
+
this.logWarning('Setting prev running status: ', prevRunningStatus);
|
|
195
|
+
this.prevRunningStatus = prevRunningStatus;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
await (await this.prepare(phases))();
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
this.logError(e);
|
|
202
|
+
}
|
|
203
|
+
process.off('SIGINT', listener);
|
|
204
|
+
await this.updateRunningStatus();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async executePhase(phaseKey, prevRunningStatus, signal) {
|
|
121
208
|
const phase = this.phases.find(phase => phase.name === phaseKey);
|
|
122
209
|
if (!phase)
|
|
123
210
|
throw new ts_common_1.BadImplementationException(`No Such Phase: ${phaseKey}`);
|
|
124
211
|
const finalPhasesToRun = resolveAllMandatoryPhases(phase).reverse();
|
|
125
|
-
|
|
212
|
+
return this.execute(finalPhasesToRun, prevRunningStatus, signal);
|
|
126
213
|
}
|
|
127
214
|
}
|
|
128
215
|
exports.ProjectManager = ProjectManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/build-and-install",
|
|
3
|
-
"version": "0.204.
|
|
3
|
+
"version": "0.204.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"chokidar": "^3.6.0",
|
|
35
|
-
"@nu-art/ts-common": "0.204.0",
|
|
36
|
-
"@nu-art/commando": "0.204.0"
|
|
35
|
+
"@nu-art/ts-common": "~0.204.0",
|
|
36
|
+
"@nu-art/commando": "~0.204.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^18.0.0"
|
package/phases/phases.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BuildPhase } from '../logic/ProjectManager';
|
|
2
|
-
export declare const projectPackages: import("../core/types").RuntimeProjectConfig;
|
|
3
2
|
export declare const Phase_PrintHelp: BuildPhase;
|
|
4
3
|
export declare const Phase_SetWithThunderstorm: BuildPhase;
|
|
5
4
|
export declare const Phase_SetupProject: BuildPhase;
|
|
5
|
+
export declare const Phase_PrepareParams: BuildPhase;
|
|
6
6
|
export declare const Phase_ResolveTemplate: BuildPhase;
|
|
7
7
|
export declare const Phase_ResolveEnv: BuildPhase;
|
|
8
8
|
export declare const Phase_ResolvePackages: BuildPhase;
|
|
@@ -17,6 +17,7 @@ export declare const Phase_InstallPackages: BuildPhase;
|
|
|
17
17
|
export declare const Phase_Clean: BuildPhase;
|
|
18
18
|
export declare const Phase_Lint: BuildPhase;
|
|
19
19
|
export declare const Phase_Debug: BuildPhase;
|
|
20
|
+
export declare const Phase_PrepareWatch: BuildPhase;
|
|
20
21
|
export declare const Phase_Compile: BuildPhase;
|
|
21
22
|
export declare const Phase_CompileWatch: BuildPhase;
|
|
22
23
|
export declare const Phase_Launch: BuildPhase;
|
package/phases/phases.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Phase_DeployBackend = exports.Phase_DeployFrontend = exports.Phase_Launch = exports.Phase_CompileWatch = exports.Phase_Compile = exports.Phase_Debug = exports.Phase_Lint = exports.Phase_Clean = exports.Phase_InstallPackages = exports.Phase_InstallPnpm = exports.Phase_InstallGlobals = exports.Phase_PackagePurge = exports.Phase_PrintEnv = exports.Phase_CheckCyclicImports = exports.Phase_PrintDependencyTree = exports.Phase_InstallNvm = exports.Phase_ResolvePackages = exports.Phase_ResolveEnv = exports.Phase_ResolveTemplate = exports.
|
|
3
|
+
exports.Phase_DeployBackend = exports.Phase_DeployFrontend = exports.Phase_Launch = exports.Phase_CompileWatch = exports.Phase_Compile = exports.Phase_PrepareWatch = exports.Phase_Debug = exports.Phase_Lint = exports.Phase_Clean = exports.Phase_InstallPackages = exports.Phase_InstallPnpm = exports.Phase_InstallGlobals = exports.Phase_PackagePurge = exports.Phase_PrintEnv = exports.Phase_CheckCyclicImports = exports.Phase_PrintDependencyTree = exports.Phase_InstallNvm = exports.Phase_ResolvePackages = exports.Phase_ResolveEnv = exports.Phase_ResolveTemplate = exports.Phase_PrepareParams = exports.Phase_SetupProject = exports.Phase_SetWithThunderstorm = exports.Phase_PrintHelp = void 0;
|
|
4
4
|
const ProjectManager_1 = require("../logic/ProjectManager");
|
|
5
5
|
const map_project_packages_1 = require("../logic/map-project-packages");
|
|
6
6
|
const fs = require("fs");
|
|
@@ -10,25 +10,21 @@ const tools_1 = require("@nu-art/commando/core/tools");
|
|
|
10
10
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
11
11
|
const types_1 = require("../core/types");
|
|
12
12
|
const generate_1 = require("../core/package/generate");
|
|
13
|
-
const consts_2 = require("../core/package/consts");
|
|
14
13
|
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
15
14
|
const params_1 = require("../core/params/params");
|
|
16
15
|
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
17
16
|
const pnpm_1 = require("@nu-art/commando/cli/pnpm");
|
|
18
17
|
const chokidar = require("chokidar");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
throw new ts_common_1.ImplementationMissingException(`Missing ./.config/project-config.ts file, could not find in path: ${pathToConfig}`);
|
|
22
|
-
const projectConfig = require(pathToConfig).default;
|
|
18
|
+
const consts_2 = require("../defaults/consts");
|
|
19
|
+
const project_manager_1 = require("../project-manager");
|
|
23
20
|
const CONST_ThunderstormVersionKey = 'THUNDERSTORM_SDK_VERSION';
|
|
24
|
-
const CONST_ThunderstormDependencyKey = '
|
|
21
|
+
const CONST_ThunderstormDependencyKey = 'THUNDERSTORM_DEPENDENCY_VERSION';
|
|
25
22
|
const CONST_ProjectVersionKey = 'APP_VERSION';
|
|
26
23
|
const CONST_ProjectDependencyKey = 'APP_VERSION_DEPENDENCY';
|
|
27
24
|
const CONST_TS_Config = `tsconfig.json`;
|
|
28
25
|
const CONST_RunningRoot = process.cwd();
|
|
29
26
|
const pathToProjectTS_Config = (0, tools_1.convertToFullPath)(`./.config/${CONST_TS_Config}`);
|
|
30
27
|
const pathToProjectEslint = (0, tools_1.convertToFullPath)('./.config/.eslintrc.js');
|
|
31
|
-
exports.projectPackages = (0, map_project_packages_1.mapProjectPackages)(projectConfig);
|
|
32
28
|
const runInDebug = false;
|
|
33
29
|
let runningWithInfra = false;
|
|
34
30
|
exports.Phase_PrintHelp = {
|
|
@@ -57,50 +53,74 @@ exports.Phase_PrintHelp = {
|
|
|
57
53
|
exports.Phase_SetWithThunderstorm = {
|
|
58
54
|
type: 'project',
|
|
59
55
|
name: 'with-ts-home',
|
|
56
|
+
isMandatory: true,
|
|
60
57
|
action: async () => {
|
|
61
58
|
var _a;
|
|
62
59
|
// set value of the running with infra flag
|
|
63
60
|
if (params_1.RuntimeParams.thunderstormHome)
|
|
64
61
|
return runningWithInfra = true;
|
|
65
62
|
// Remove all the infra packages from the runtime project
|
|
66
|
-
|
|
63
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
64
|
+
packages.packagesDependency = (_a = packages.packagesDependency) === null || _a === void 0 ? void 0 : _a.map(_packageArray => _packageArray.filter(_package => _package.type !== types_1.PackageType_InfraLib));
|
|
67
65
|
return runningWithInfra = false;
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
exports.Phase_SetupProject = {
|
|
71
69
|
type: 'project',
|
|
72
70
|
name: 'setup-project',
|
|
71
|
+
isMandatory: true,
|
|
73
72
|
action: async () => {
|
|
74
73
|
const thunderstormVersionJson = require((0, tools_1.convertToFullPath)('./version-thunderstorm.json'));
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
75
|
+
packages.params[CONST_ThunderstormVersionKey] = thunderstormVersionJson.version;
|
|
76
|
+
packages.params[CONST_ThunderstormDependencyKey] = `~${thunderstormVersionJson.version}`;
|
|
77
77
|
const projectVersionJson = require((0, tools_1.convertToFullPath)('./version-app.json'));
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
packages.params[CONST_ProjectVersionKey] = projectVersionJson.version;
|
|
79
|
+
packages.params[CONST_ProjectDependencyKey] = projectVersionJson.version;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.Phase_PrepareParams = {
|
|
83
|
+
type: 'package',
|
|
84
|
+
name: 'prepare-params',
|
|
85
|
+
isMandatory: true,
|
|
86
|
+
breakAfterPhase: true,
|
|
87
|
+
mandatoryPhases: [exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
88
|
+
action: async (pkg) => {
|
|
89
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
90
|
+
// with workspace: *
|
|
91
|
+
const tempPackageJson = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
92
|
+
const toRet = packages.params[key] ? 'workspace:*' : packages.params[value];
|
|
93
|
+
return toRet;
|
|
94
|
+
});
|
|
95
|
+
// placed package name to version
|
|
96
|
+
packages.params[tempPackageJson.name] = tempPackageJson.version;
|
|
97
|
+
packages.params[`${tempPackageJson.name}_path`] = `file:.dependencies/${pkg.name}`;
|
|
80
98
|
}
|
|
81
99
|
};
|
|
82
100
|
exports.Phase_ResolveTemplate = {
|
|
83
101
|
type: 'package',
|
|
84
102
|
name: 'resolve-template',
|
|
85
|
-
|
|
103
|
+
isMandatory: true,
|
|
104
|
+
mandatoryPhases: [exports.Phase_PrepareParams, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
86
105
|
action: async (pkg) => {
|
|
106
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
87
107
|
// with workspace: *
|
|
88
108
|
pkg.packageJsonWorkspace = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
89
|
-
const toRet =
|
|
109
|
+
const toRet = packages.params[key] ? 'workspace:*' : packages.params[value];
|
|
90
110
|
return toRet;
|
|
91
111
|
});
|
|
92
112
|
// placed package name to version
|
|
93
|
-
|
|
94
|
-
|
|
113
|
+
packages.params[pkg.packageJsonWorkspace.name] = pkg.packageJsonWorkspace.version;
|
|
114
|
+
packages.params[`${pkg.packageJsonWorkspace.name}_path`] = `file:.dependencies/${pkg.name}`;
|
|
95
115
|
// with versions for all packages, for be output: file:.dependencies/${pkg.name}
|
|
96
116
|
pkg.packageJsonOutput = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
97
117
|
var _a;
|
|
98
|
-
const toRet = (_a =
|
|
118
|
+
const toRet = (_a = packages.params[key]) !== null && _a !== void 0 ? _a : packages.params[value];
|
|
99
119
|
return toRet;
|
|
100
120
|
});
|
|
101
121
|
pkg.packageJsonRuntime = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
102
122
|
var _a, _b;
|
|
103
|
-
const toRet = (_b = (_a =
|
|
123
|
+
const toRet = (_b = (_a = packages.params[`${key}_path`]) !== null && _a !== void 0 ? _a : packages.params[key]) !== null && _b !== void 0 ? _b : packages.params[value];
|
|
104
124
|
return toRet;
|
|
105
125
|
});
|
|
106
126
|
// write final package.json to package root folder
|
|
@@ -115,12 +135,14 @@ exports.Phase_ResolveTemplate = {
|
|
|
115
135
|
exports.Phase_ResolveEnv = {
|
|
116
136
|
type: 'package',
|
|
117
137
|
name: 'resolve-env',
|
|
138
|
+
isMandatory: true,
|
|
118
139
|
mandatoryPhases: [exports.Phase_ResolveTemplate, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
119
140
|
filter: async (pkg) => pkg.type === 'firebase-functions-app' || pkg.type === 'firebase-hosting-app',
|
|
120
141
|
action: async (pkg) => {
|
|
121
142
|
var _a, _b;
|
|
122
143
|
const firebasePkg = pkg;
|
|
123
144
|
await fs_1.promises.writeFile(`${firebasePkg.path}/${consts_1.CONST_FirebaseRC}`, JSON.stringify((0, generate_1.createFirebaseRC)(firebasePkg, params_1.RuntimeParams.setEnv), null, 2), { encoding: 'utf-8' });
|
|
145
|
+
const defaultFiles = consts_2.MemKey_DefaultFiles.get();
|
|
124
146
|
let fileContent;
|
|
125
147
|
if (pkg.type === 'firebase-hosting-app')
|
|
126
148
|
fileContent = (0, generate_1.createFirebaseHostingJSON)(firebasePkg, params_1.RuntimeParams.setEnv);
|
|
@@ -139,20 +161,20 @@ exports.Phase_ResolveEnv = {
|
|
|
139
161
|
await fs_1.promises.access(pathToProxyFile);
|
|
140
162
|
}
|
|
141
163
|
catch (e) {
|
|
142
|
-
let defaultFileContent = await fs_1.promises.readFile(
|
|
164
|
+
let defaultFileContent = await fs_1.promises.readFile(defaultFiles.backend.proxy, { encoding: 'utf-8' });
|
|
143
165
|
defaultFileContent = defaultFileContent.replace(/SERVER_PORT/g, `${firebasePkg.envConfig.basePort}`);
|
|
144
166
|
defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_KEY/g, `${(_a = firebasePkg.envConfig.ssl) === null || _a === void 0 ? void 0 : _a.pathToKey}`);
|
|
145
167
|
defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_b = firebasePkg.envConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToCertificate}`);
|
|
146
168
|
await fs_1.promises.writeFile(pathToProxyFile, defaultFileContent, { encoding: 'utf-8' });
|
|
147
169
|
}
|
|
148
170
|
}
|
|
149
|
-
await Promise.all(consts_2.
|
|
150
|
-
const pathToConfigFile = `${pathToFirebaseConfigFolder}/${
|
|
171
|
+
await Promise.all(consts_2.Const_FirebaseConfigKeys.map(async (firebaseConfigKey) => {
|
|
172
|
+
const pathToConfigFile = `${pathToFirebaseConfigFolder}/${consts_2.Const_FirebaseDefaultsKeyToFile[firebaseConfigKey]}`;
|
|
151
173
|
try {
|
|
152
174
|
await fs_1.promises.access(pathToConfigFile);
|
|
153
175
|
}
|
|
154
176
|
catch (e) {
|
|
155
|
-
const defaultFileContent = await fs_1.promises.readFile(
|
|
177
|
+
const defaultFileContent = await fs_1.promises.readFile(defaultFiles.firebaseConfig[firebaseConfigKey], { encoding: 'utf-8' });
|
|
156
178
|
await fs_1.promises.writeFile(pathToConfigFile, defaultFileContent, { encoding: 'utf-8' });
|
|
157
179
|
}
|
|
158
180
|
}));
|
|
@@ -256,7 +278,8 @@ exports.Phase_InstallPackages = {
|
|
|
256
278
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
257
279
|
filter: async () => params_1.RuntimeParams.installPackages,
|
|
258
280
|
action: async () => {
|
|
259
|
-
const
|
|
281
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
282
|
+
const listOfLibs = packages.packages
|
|
260
283
|
.filter(pkg => runningWithInfra || ['project-lib', 'app', 'sourceless'].includes(pkg.type))
|
|
261
284
|
.map(pkg => pkg.path.replace(`${process.cwd()}/`, '').replace(process.cwd(), '.'));
|
|
262
285
|
await pnpm_1.PNPM.createWorkspace(listOfLibs);
|
|
@@ -291,7 +314,8 @@ exports.Phase_Debug = {
|
|
|
291
314
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
292
315
|
filter: async () => params_1.RuntimeParams.debug,
|
|
293
316
|
action: async () => {
|
|
294
|
-
|
|
317
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
318
|
+
console.log(JSON.stringify(packages, null, 2));
|
|
295
319
|
}
|
|
296
320
|
};
|
|
297
321
|
const sourcesPaths = [];
|
|
@@ -303,13 +327,13 @@ const suffixes = [
|
|
|
303
327
|
'svg',
|
|
304
328
|
];
|
|
305
329
|
const compileActions = {};
|
|
306
|
-
exports.
|
|
330
|
+
exports.Phase_PrepareWatch = {
|
|
307
331
|
type: 'package',
|
|
308
|
-
name: 'compile',
|
|
332
|
+
name: 'prepare-compile',
|
|
333
|
+
isMandatory: true,
|
|
309
334
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
310
335
|
filter: async (pkg) => pkg.type !== 'sourceless' && !params_1.RuntimeParams.noBuild,
|
|
311
336
|
action: async (pkg) => {
|
|
312
|
-
var _a;
|
|
313
337
|
if (pkg.type === 'sourceless')
|
|
314
338
|
return;
|
|
315
339
|
const folder = 'main';
|
|
@@ -317,17 +341,41 @@ exports.Phase_Compile = {
|
|
|
317
341
|
suffixes.forEach(suffix => {
|
|
318
342
|
sourcesPaths.push(`${sourceFolder}/**/*.${suffix}`);
|
|
319
343
|
});
|
|
344
|
+
// --- HERE ---
|
|
345
|
+
compileActions[sourceFolder] = async () => {
|
|
346
|
+
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
347
|
+
const commando = nvm_1.NVM.createCommando();
|
|
348
|
+
await commando
|
|
349
|
+
.append(`tsc -p "${pathToLocalTsConfig}" --rootDir "${sourceFolder}" --outDir "${pkg.output}"`)
|
|
350
|
+
.execute();
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
exports.Phase_Compile = {
|
|
355
|
+
type: 'package',
|
|
356
|
+
name: 'compile',
|
|
357
|
+
mandatoryPhases: [exports.Phase_PrepareWatch],
|
|
358
|
+
filter: async (pkg) => pkg.type !== 'sourceless' && !params_1.RuntimeParams.noBuild,
|
|
359
|
+
action: async (pkg) => {
|
|
360
|
+
var _a;
|
|
361
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
362
|
+
if (pkg.type === 'sourceless')
|
|
363
|
+
return;
|
|
364
|
+
const folder = 'main';
|
|
365
|
+
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
320
366
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
321
|
-
const
|
|
322
|
-
|
|
367
|
+
const inPackageTsConfig = await fs_1.promises.readFile(pathToProjectTS_Config, { encoding: 'utf-8' });
|
|
368
|
+
const defaultPackageTsConfig = await fs_1.promises.readFile(pathToProjectTS_Config, { encoding: 'utf-8' });
|
|
369
|
+
if (!pkg.customTsConfig && inPackageTsConfig !== defaultPackageTsConfig) {
|
|
323
370
|
await fs_1.promises.copyFile(pathToProjectTS_Config, pathToLocalTsConfig);
|
|
371
|
+
}
|
|
324
372
|
// --- HERE ---
|
|
325
373
|
await fs_1.promises.writeFile(`${pkg.output}/${consts_1.CONST_PackageJSON}`, JSON.stringify(pkg.packageJsonOutput, null, 2), { encoding: 'utf-8' });
|
|
326
374
|
if (pkg.type == 'firebase-functions-app') {
|
|
327
375
|
pkg.packageJsonRuntime.main = pkg.packageJsonRuntime.main.replace('dist/', '');
|
|
328
376
|
pkg.packageJsonRuntime.types = pkg.packageJsonRuntime.types.replace('dist/', '');
|
|
329
377
|
await fs_1.promises.writeFile(`${pkg.output}/${consts_1.CONST_PackageJSON}`, JSON.stringify(pkg.packageJsonRuntime, null, 2), { encoding: 'utf-8' });
|
|
330
|
-
const runTimePackages = (0, ts_common_1.filterDuplicates)((_a =
|
|
378
|
+
const runTimePackages = (0, ts_common_1.filterDuplicates)((_a = packages.packagesDependency) === null || _a === void 0 ? void 0 : _a.flat().filter(_pkg => {
|
|
331
379
|
var _a, _b;
|
|
332
380
|
if (_pkg.name === pkg.name)
|
|
333
381
|
return false;
|
|
@@ -348,51 +396,80 @@ exports.Phase_Compile = {
|
|
|
348
396
|
}
|
|
349
397
|
}
|
|
350
398
|
}
|
|
351
|
-
compileActions[sourceFolder] = async (deleteDist) => {
|
|
352
|
-
if (deleteDist)
|
|
353
|
-
await fs_1.promises.rmdir(pkg.output);
|
|
354
|
-
await commando
|
|
355
|
-
.append(`tsc -p "${pathToLocalTsConfig}" --rootDir "${sourceFolder}" --outDir "${pkg.output}"`)
|
|
356
|
-
.execute();
|
|
357
|
-
};
|
|
358
399
|
return compileActions[sourceFolder]();
|
|
359
400
|
}
|
|
360
401
|
};
|
|
361
402
|
exports.Phase_CompileWatch = {
|
|
362
403
|
type: 'project',
|
|
363
404
|
name: 'compile-watch',
|
|
364
|
-
|
|
405
|
+
terminatingPhase: true,
|
|
406
|
+
mandatoryPhases: [exports.Phase_PrepareWatch],
|
|
365
407
|
filter: async () => params_1.RuntimeParams.watch,
|
|
366
408
|
action: async () => {
|
|
367
409
|
const watcher = chokidar.watch(sourcesPaths);
|
|
368
|
-
const
|
|
410
|
+
const projectManager = project_manager_1.MemKey_ProjectManager.get();
|
|
411
|
+
await project_manager_1.MemKey_ProjectManager.get().updateRunningStatus({
|
|
412
|
+
'phaseKey': 'compile-watch',
|
|
413
|
+
'packageDependencyIndex': 0
|
|
414
|
+
});
|
|
415
|
+
let controller;
|
|
416
|
+
const watchListener = async (path, deleteDist) => {
|
|
369
417
|
const libPath = (0, ts_common_1._keys)(compileActions).find(libPath => path.startsWith(libPath));
|
|
370
418
|
if (!libPath)
|
|
371
419
|
return console.error(`couldn't find lib to run for path: ${libPath}...\nListening on: ${(0, ts_common_1.__stringify)(sourcesPaths, true)}`);
|
|
372
|
-
|
|
420
|
+
const rtPackages = consts_1.MemKey_Packages.get();
|
|
421
|
+
const pkg = (0, ts_common_1.flatArray)(rtPackages.packagesDependency).find(pkg => {
|
|
422
|
+
return path.startsWith(pkg.path) && pkg.type !== 'sourceless';
|
|
423
|
+
});
|
|
424
|
+
if (deleteDist && pkg && 'output' in pkg)
|
|
425
|
+
await fs_1.promises.rmdir(pkg.output);
|
|
426
|
+
const packageIndex = rtPackages.packagesDependency.findIndex(packages => {
|
|
427
|
+
return packages.some(pkg => path.startsWith(pkg.path) && pkg.type !== 'sourceless');
|
|
428
|
+
});
|
|
429
|
+
try {
|
|
430
|
+
if (controller)
|
|
431
|
+
controller.abort();
|
|
432
|
+
controller = new AbortController();
|
|
433
|
+
await projectManager.executePhase('compile', { phaseKey: 'compile', packageDependencyIndex: packageIndex }, controller.signal);
|
|
434
|
+
}
|
|
435
|
+
catch (e) {
|
|
436
|
+
console.log(e);
|
|
437
|
+
}
|
|
373
438
|
};
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
439
|
+
return new Promise((resolve, error) => {
|
|
440
|
+
watcher
|
|
441
|
+
.on('error', (error) => {
|
|
442
|
+
console.log(`error`, error);
|
|
443
|
+
})
|
|
444
|
+
.on('ready', () => {
|
|
445
|
+
console.log('Watching: ', sourcesPaths);
|
|
446
|
+
watcher
|
|
447
|
+
.on('add', (path) => {
|
|
448
|
+
console.log(`New File added: ${path}`);
|
|
449
|
+
watchListener(path);
|
|
450
|
+
})
|
|
451
|
+
.on('change', (path) => {
|
|
452
|
+
console.log(`Detected changes in file: ${path}`);
|
|
453
|
+
watchListener(path);
|
|
454
|
+
})
|
|
455
|
+
.on('unlinkDir', (path) => {
|
|
456
|
+
console.log(`Deleted Directory: ${path}`);
|
|
457
|
+
watchListener(path, true);
|
|
458
|
+
})
|
|
459
|
+
.on('unlink', (path) => {
|
|
460
|
+
console.log(`File Deleted: ${path}`);
|
|
461
|
+
watchListener(path, true);
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
process.on('SIGINT', async (status) => {
|
|
465
|
+
await watcher.close();
|
|
466
|
+
await project_manager_1.MemKey_ProjectManager.get().updateRunningStatus({
|
|
467
|
+
'phaseKey': 'compile-watch',
|
|
468
|
+
'packageDependencyIndex': 0
|
|
469
|
+
});
|
|
470
|
+
process.exit(0);
|
|
471
|
+
resolve();
|
|
472
|
+
});
|
|
396
473
|
});
|
|
397
474
|
}
|
|
398
475
|
};
|
|
@@ -400,6 +477,7 @@ let counter = 0;
|
|
|
400
477
|
exports.Phase_Launch = {
|
|
401
478
|
type: 'package',
|
|
402
479
|
name: 'launch',
|
|
480
|
+
terminatingPhase: true,
|
|
403
481
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
404
482
|
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'); },
|
|
405
483
|
action: async (pkg) => {
|
|
@@ -429,6 +507,7 @@ exports.Phase_Launch = {
|
|
|
429
507
|
exports.Phase_DeployFrontend = {
|
|
430
508
|
type: 'package',
|
|
431
509
|
name: 'deploy-frontend',
|
|
510
|
+
terminatingPhase: true,
|
|
432
511
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
433
512
|
filter: async (pkg) => {
|
|
434
513
|
var _a;
|
|
@@ -446,6 +525,7 @@ exports.Phase_DeployFrontend = {
|
|
|
446
525
|
exports.Phase_DeployBackend = {
|
|
447
526
|
type: 'package',
|
|
448
527
|
name: 'deploy-functions',
|
|
528
|
+
terminatingPhase: true,
|
|
449
529
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
450
530
|
filter: async (pkg) => { var _a; return !!((_a = pkg.name.match(new RegExp(params_1.RuntimeParams.deploy))) === null || _a === void 0 ? void 0 : _a[0]) && pkg.type === 'firebase-functions-app'; },
|
|
451
531
|
action: async (pkg) => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemKey_AbortSignal = exports.MemKey_ProjectManager = void 0;
|
|
4
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
5
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
6
|
+
const params_1 = require("./core/params/params");
|
|
7
|
+
exports.MemKey_ProjectManager = new MemStorage_1.MemKey('ProjectManager', true);
|
|
8
|
+
exports.MemKey_AbortSignal = new MemStorage_1.MemKey('AbortSignal', true);
|
|
9
|
+
ts_common_1.DebugFlag.DefaultLogLevel = params_1.RuntimeParams.debug ? ts_common_1.LogLevel.Debug : ts_common_1.LogLevel.Info;
|