@nu-art/build-and-install 0.300.7 → 0.400.0
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-v3.d.ts +29 -0
- package/build-and-install-v3.js +132 -0
- package/build-and-install-v3.js.map +1 -0
- package/build-and-install.js +18 -24
- package/build-and-install.js.map +1 -0
- package/core/consts.d.ts +7 -2
- package/core/consts.js +12 -9
- package/core/consts.js.map +1 -0
- package/core/exceptions/PhaseAggregatedException.d.ts +5 -0
- package/core/exceptions/PhaseAggregatedException.js +9 -0
- package/core/exceptions/PhaseAggregatedException.js.map +1 -0
- package/core/package/consts.d.ts +1 -1
- package/core/package/consts.js +7 -9
- package/core/package/consts.js.map +1 -0
- package/core/params/params.d.ts +18 -19
- package/core/params/params.js +142 -178
- package/core/params/params.js.map +1 -0
- package/core/types/configs/firebasejson.js +2 -2
- package/core/types/configs/firebasejson.js.map +1 -0
- package/core/types/configs/firebaserc.js +2 -2
- package/core/types/configs/firebaserc.js.map +1 -0
- package/core/types/configs/index.d.ts +3 -3
- package/core/types/configs/index.js +4 -19
- package/core/types/configs/index.js.map +1 -0
- package/core/types/configs/package-json.d.ts +2 -1
- package/core/types/configs/package-json.js +2 -2
- package/core/types/configs/package-json.js.map +1 -0
- package/core/types/core.js +2 -2
- package/core/types/core.js.map +1 -0
- package/core/types/index.d.ts +4 -4
- package/core/types/index.js +5 -20
- package/core/types/index.js.map +1 -0
- package/core/types/package/index.d.ts +2 -2
- package/core/types/package/index.js +3 -18
- package/core/types/package/index.js.map +1 -0
- package/core/types/package/package.d.ts +10 -14
- package/core/types/package/package.js +15 -12
- package/core/types/package/package.js.map +1 -0
- package/core/types/package/runtime-package.d.ts +2 -2
- package/core/types/package/runtime-package.js +2 -2
- package/core/types/package/runtime-package.js.map +1 -0
- package/core/types/project-config.d.ts +31 -2
- package/core/types/project-config.js +2 -2
- package/core/types/project-config.js.map +1 -0
- package/defaults/backend-proxy/proxy._ts +3 -1
- package/defaults/consts.d.ts +0 -7
- package/defaults/consts.js +10 -10
- package/defaults/consts.js.map +1 -0
- package/{v2/phase-runner → old}/PhaseRunnerDispatcher.d.ts +4 -4
- package/old/PhaseRunnerDispatcher.js +33 -0
- package/old/PhaseRunnerDispatcher.js.map +1 -0
- package/{v2/unit → old}/runner-dispatchers.d.ts +3 -3
- package/old/runner-dispatchers.js +4 -0
- package/old/runner-dispatchers.js.map +1 -0
- package/package.json +20 -15
- package/v3/PhaseManager.d.ts +26 -0
- package/v3/PhaseManager.js +144 -0
- package/v3/PhaseManager.js.map +1 -0
- package/v3/RunningStatusHandler.d.ts +16 -0
- package/v3/RunningStatusHandler.js +57 -0
- package/v3/RunningStatusHandler.js.map +1 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.d.ts +52 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js +287 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js.map +1 -0
- package/v3/UnitsMapper/UnitsMapper.d.ts +21 -0
- package/v3/UnitsMapper/UnitsMapper.js +60 -0
- package/v3/UnitsMapper/UnitsMapper.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.d.ts +23 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +17 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.d.ts +62 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +56 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.d.ts +38 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +49 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.d.ts +30 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +59 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.d.ts +25 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js +29 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.d.ts +24 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js +23 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js.map +1 -0
- package/v3/UnitsMapper/resolvers/index.d.ts +4 -0
- package/v3/UnitsMapper/resolvers/index.js +5 -0
- package/v3/UnitsMapper/resolvers/index.js.map +1 -0
- package/v3/UnitsMapper/types.d.ts +24 -0
- package/v3/UnitsMapper/types.js +2 -0
- package/v3/UnitsMapper/types.js.map +1 -0
- package/v3/core/FileSystemUtils.d.ts +34 -0
- package/v3/core/FileSystemUtils.js +152 -0
- package/v3/core/FileSystemUtils.js.map +1 -0
- package/v3/core/FilesCache.d.ts +7 -0
- package/v3/core/FilesCache.js +34 -0
- package/v3/core/FilesCache.js.map +1 -0
- package/v3/core/Unit_HelpPrinter.d.ts +16 -0
- package/v3/core/Unit_HelpPrinter.js +48 -0
- package/v3/core/Unit_HelpPrinter.js.map +1 -0
- package/v3/core/types.d.ts +17 -0
- package/v3/core/types.js +6 -0
- package/v3/core/types.js.map +1 -0
- package/v3/phase/consts.d.ts +52 -0
- package/v3/phase/consts.js +127 -0
- package/v3/phase/consts.js.map +1 -0
- package/v3/phase/index.d.ts +2 -0
- package/v3/phase/index.js +3 -0
- package/v3/phase/index.js.map +1 -0
- package/v3/phase/types.d.ts +9 -0
- package/v3/phase/types.js +2 -0
- package/v3/phase/types.js.map +1 -0
- package/v3/units/BaseUnit.d.ts +46 -0
- package/v3/units/BaseUnit.js +120 -0
- package/v3/units/BaseUnit.js.map +1 -0
- package/v3/units/ProjectUnit.d.ts +18 -0
- package/v3/units/ProjectUnit.js +12 -0
- package/v3/units/ProjectUnit.js.map +1 -0
- package/v3/units/Unit_NodeProject.d.ts +32 -0
- package/v3/units/Unit_NodeProject.js +244 -0
- package/v3/units/Unit_NodeProject.js.map +1 -0
- package/v3/units/Unit_PackageJson.d.ts +19 -0
- package/v3/units/Unit_PackageJson.js +42 -0
- package/v3/units/Unit_PackageJson.js.map +1 -0
- package/v3/units/Unit_TypescriptLib.d.ts +45 -0
- package/v3/units/Unit_TypescriptLib.js +373 -0
- package/v3/units/Unit_TypescriptLib.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +62 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +281 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +49 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +100 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js.map +1 -0
- package/v3/units/index.d.ts +5 -0
- package/v3/units/index.js +6 -0
- package/v3/units/index.js.map +1 -0
- package/core/params/types.d.ts +0 -51
- package/core/params/types.js +0 -2
- package/tsconfig.json +0 -23
- package/v2/phase/consts.d.ts +0 -53
- package/v2/phase/consts.js +0 -149
- package/v2/phase/index.d.ts +0 -2
- package/v2/phase/index.js +0 -18
- package/v2/phase/types.d.ts +0 -12
- package/v2/phase/types.js +0 -2
- package/v2/phase-runner/PhaseRunner.d.ts +0 -69
- package/v2/phase-runner/PhaseRunner.js +0 -472
- package/v2/phase-runner/PhaseRunnerDispatcher.js +0 -37
- package/v2/phase-runner/RunnerParams.d.ts +0 -12
- package/v2/phase-runner/RunnerParams.js +0 -9
- package/v2/phase-runner/consts.d.ts +0 -7
- package/v2/phase-runner/consts.js +0 -9
- package/v2/phase-runner/kaki.d.ts +0 -0
- package/v2/phase-runner/kaki.js +0 -1
- package/v2/phase-runner/types.d.ts +0 -13
- package/v2/phase-runner/types.js +0 -6
- package/v2/project/types.d.ts +0 -8
- package/v2/project/types.js +0 -2
- package/v2/screens/BAIScreen.d.ts +0 -22
- package/v2/screens/BAIScreen.js +0 -82
- package/v2/screens/BAIScreenManager.d.ts +0 -28
- package/v2/screens/BAIScreenManager.js +0 -77
- package/v2/screens/BAIScreen_Launch.d.ts +0 -28
- package/v2/screens/BAIScreen_Launch.js +0 -173
- package/v2/screens/BAIScreen_UnitList.d.ts +0 -36
- package/v2/screens/BAIScreen_UnitList.js +0 -203
- package/v2/unit/consts.d.ts +0 -6
- package/v2/unit/consts.js +0 -8
- package/v2/unit/core/BaseUnit.d.ts +0 -39
- package/v2/unit/core/BaseUnit.js +0 -138
- package/v2/unit/core/Unit_Python.d.ts +0 -16
- package/v2/unit/core/Unit_Python.js +0 -26
- package/v2/unit/core/Unit_Typescript.d.ts +0 -49
- package/v2/unit/core/Unit_Typescript.js +0 -143
- package/v2/unit/core/Unit_TypescriptLib.d.ts +0 -48
- package/v2/unit/core/Unit_TypescriptLib.js +0 -226
- package/v2/unit/core/Unit_TypescriptProject.d.ts +0 -31
- package/v2/unit/core/Unit_TypescriptProject.js +0 -194
- package/v2/unit/core/index.d.ts +0 -5
- package/v2/unit/core/index.js +0 -21
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.d.ts +0 -35
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +0 -309
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.d.ts +0 -24
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +0 -138
- package/v2/unit/firebase-units/consts.d.ts +0 -2
- package/v2/unit/firebase-units/consts.js +0 -9
- package/v2/unit/firebase-units/index.d.ts +0 -2
- package/v2/unit/firebase-units/index.js +0 -18
- package/v2/unit/runner-dispatchers.js +0 -6
- package/v2/unit/thunderstorm.d.ts +0 -171
- package/v2/unit/thunderstorm.js +0 -199
- package/v2/unit/tools/tools.d.ts +0 -2
- package/v2/unit/tools/tools.js +0 -15
- package/v2/unit/types.d.ts +0 -8
- package/v2/unit/types.js +0 -2
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Unit_TypescriptLib = void 0;
|
|
27
|
-
const Unit_Typescript_1 = require("./Unit_Typescript");
|
|
28
|
-
const fs = __importStar(require("fs"));
|
|
29
|
-
const fs_1 = require("fs");
|
|
30
|
-
const ts_common_1 = require("@nu-art/ts-common");
|
|
31
|
-
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
32
|
-
const consts_1 = require("../../../core/consts");
|
|
33
|
-
const params_1 = require("../../../core/params/params");
|
|
34
|
-
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
35
|
-
const CliError_1 = require("@nu-art/commando/shell/core/CliError");
|
|
36
|
-
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
37
|
-
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
38
|
-
const extensionsToLint = ['ts', 'tsx'];
|
|
39
|
-
const assetExtensions = [
|
|
40
|
-
'json',
|
|
41
|
-
'scss',
|
|
42
|
-
'svg',
|
|
43
|
-
'png',
|
|
44
|
-
'jpg',
|
|
45
|
-
'jpeg',
|
|
46
|
-
'rules',
|
|
47
|
-
'_ts'
|
|
48
|
-
];
|
|
49
|
-
class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
50
|
-
constructor(config) {
|
|
51
|
-
super(config);
|
|
52
|
-
this.addToClassStack(Unit_TypescriptLib);
|
|
53
|
-
}
|
|
54
|
-
async __onWatchReady() {
|
|
55
|
-
return this.setStatus('Watching');
|
|
56
|
-
}
|
|
57
|
-
async init(setInitialized = true) {
|
|
58
|
-
await super.init(false);
|
|
59
|
-
runner_dispatchers_1.dispatcher_WatchReady.addListener(this);
|
|
60
|
-
this.runtime.pathTo.output = this.runtime.pathTo.pkg + `/${this.config.output}`;
|
|
61
|
-
if (setInitialized)
|
|
62
|
-
this.setStatus('Initialized');
|
|
63
|
-
}
|
|
64
|
-
//######################### Internal Logic #########################
|
|
65
|
-
async resolveTSConfig() {
|
|
66
|
-
const pathToUnitTSConfig = `${this.runtime.pathTo.pkg}/src/main/tsconfig.json`;
|
|
67
|
-
// const pathToProjectTSConfig = '';
|
|
68
|
-
//If set to use a custom ts config
|
|
69
|
-
if (this.config.customTSConfig) {
|
|
70
|
-
//If ts config file does not exist in the main folder
|
|
71
|
-
if (!fs.existsSync(pathToUnitTSConfig))
|
|
72
|
-
throw new ts_common_1.BadImplementationException(`Unit "${this.config.label}" is set to use a custom tsconfig but is missing a tsconfig.json file in /src/main`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
//Copy project ts config file into the unit main folder
|
|
76
|
-
const pathToProjectConfig = this.getRunnerParam(RunnerParams_1.RunnerParamKey_ConfigPath);
|
|
77
|
-
if (!pathToProjectConfig)
|
|
78
|
-
throw new ts_common_1.BadImplementationException('Could not get config path from runner params');
|
|
79
|
-
//Make sure a project ts config file exists
|
|
80
|
-
const pathToProjectTSConfig = pathToProjectConfig + '/tsconfig.json';
|
|
81
|
-
if (!fs.existsSync(pathToProjectTSConfig))
|
|
82
|
-
throw new ts_common_1.BadImplementationException(`Project is missing a tsconfig.json file in path ${pathToProjectConfig}`);
|
|
83
|
-
//Copy the file into the unit
|
|
84
|
-
await fs_1.promises.copyFile(pathToProjectTSConfig, pathToUnitTSConfig);
|
|
85
|
-
}
|
|
86
|
-
async clearOutputDir() {
|
|
87
|
-
if (!params_1.RuntimeParams.clean)
|
|
88
|
-
return;
|
|
89
|
-
//Return if output dir doesn't exist
|
|
90
|
-
if (!fs.existsSync(this.runtime.pathTo.output))
|
|
91
|
-
return;
|
|
92
|
-
await fs_1.promises.rm(this.runtime.pathTo.output, { recursive: true, force: true });
|
|
93
|
-
await fs_1.promises.mkdir(this.runtime.pathTo.output, { recursive: true });
|
|
94
|
-
}
|
|
95
|
-
async compileImpl() {
|
|
96
|
-
const pathToCompile = `${this.runtime.pathTo.pkg}/src/main`;
|
|
97
|
-
const pathToTSConfig = `${pathToCompile}/tsconfig.json`;
|
|
98
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic)
|
|
99
|
-
.cd(this.runtime.pathTo.pkg)
|
|
100
|
-
.append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
|
|
101
|
-
.setLogLevelFilter((log, std) => {
|
|
102
|
-
return ts_common_1.LogLevel.Error;
|
|
103
|
-
})
|
|
104
|
-
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
|
|
105
|
-
await this.executeAsyncCommando(commando, (stdout, stderr, exitCode) => {
|
|
106
|
-
if (stderr.length)
|
|
107
|
-
this.logError(stderr);
|
|
108
|
-
if (exitCode > 0)
|
|
109
|
-
throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
async copyAssetsToOutput() {
|
|
113
|
-
const command = `find . \\( -name ${assetExtensions.map(suffix => `'*.${suffix}'`)
|
|
114
|
-
.join(' -o -name ')} \\) | cpio -pdmuv "${this.runtime.pathTo.output}" > /dev/null 2>&1`;
|
|
115
|
-
await this.allocateCommando(basic_1.Commando_Basic)
|
|
116
|
-
.cd(`${this.runtime.pathTo.pkg}/src/main`)
|
|
117
|
-
// .setStdErrorValidator(stderr => {
|
|
118
|
-
// return !stderr.match(/\d+\sblock/);
|
|
119
|
-
// })
|
|
120
|
-
.append(command)
|
|
121
|
-
.execute();
|
|
122
|
-
}
|
|
123
|
-
async copyPackageJSONToOutput() {
|
|
124
|
-
const targetPath = `${this.runtime.pathTo.output}/${consts_1.CONST_PackageJSON}`;
|
|
125
|
-
const fileContent = JSON.stringify(this.packageJson.dist, null, 2);
|
|
126
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Watch compile actions, use this to perform all necessary compile actions for watch.
|
|
130
|
-
* watch compile is a subset of the general watch action
|
|
131
|
-
*/
|
|
132
|
-
async watchCompile() {
|
|
133
|
-
try {
|
|
134
|
-
this.setStatus('Compiling', 'start');
|
|
135
|
-
// perform all watch actions
|
|
136
|
-
await this.compileImpl();
|
|
137
|
-
await this.copyAssetsToOutput();
|
|
138
|
-
this.setStatus(`Compiled and Watching`, 'end');
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
this.setStatus(`Watching with error`, e);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Remove the deleted file/folder from the dist folder on watch remove file event
|
|
146
|
-
* @param path The path of the currently removed file/folder
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
async removeSpecificFileFromDist(path) {
|
|
150
|
-
this.setStatus('Removing files from dist', 'start');
|
|
151
|
-
const distPathBase = path.replace('src/main', 'dist').replace(/\.ts$/, '');
|
|
152
|
-
const pathsToDelete = [
|
|
153
|
-
`${distPathBase}.js`,
|
|
154
|
-
`${distPathBase}.d.ts`,
|
|
155
|
-
`${distPathBase}.js.map`,
|
|
156
|
-
distPathBase // in case it's a directory
|
|
157
|
-
];
|
|
158
|
-
// try to remove all path options from dist
|
|
159
|
-
for (const path of pathsToDelete) {
|
|
160
|
-
if (!fs.existsSync(path)) {
|
|
161
|
-
this.logDebug(`no file in path ${path}`);
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
await fs_1.promises.rm(path, { recursive: true, force: true });
|
|
165
|
-
}
|
|
166
|
-
this.setStatus('Files Removed and watching', 'end');
|
|
167
|
-
}
|
|
168
|
-
//######################### Phase Implementations #########################
|
|
169
|
-
async preCompile() {
|
|
170
|
-
if (!fs.existsSync(`${this.config.pathToPackage}/prebuild.sh`))
|
|
171
|
-
return;
|
|
172
|
-
this.setStatus('Pre-Compile');
|
|
173
|
-
await this.allocateCommando(basic_1.Commando_Basic)
|
|
174
|
-
.cd(this.runtime.pathTo.pkg)
|
|
175
|
-
.append('bash prebuild.sh')
|
|
176
|
-
.execute();
|
|
177
|
-
}
|
|
178
|
-
async compile() {
|
|
179
|
-
try {
|
|
180
|
-
this.setStatus('Compiling', 'start');
|
|
181
|
-
await this.resolveTSConfig();
|
|
182
|
-
await this.clearOutputDir();
|
|
183
|
-
await this.compileImpl();
|
|
184
|
-
await this.copyAssetsToOutput();
|
|
185
|
-
await this.copyPackageJSONToOutput();
|
|
186
|
-
this.setStatus(`Compiled`, 'end');
|
|
187
|
-
}
|
|
188
|
-
catch (e) {
|
|
189
|
-
this.setErrorStatus('Compilation Error', e);
|
|
190
|
-
if (!params_1.RuntimeParams.watch)
|
|
191
|
-
throw e;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async purge() {
|
|
195
|
-
await fs_1.promises.rm(this.runtime.pathTo.output, { recursive: true, force: true });
|
|
196
|
-
}
|
|
197
|
-
async printDependencyTree() {
|
|
198
|
-
const CONST_RunningRoot = process.cwd();
|
|
199
|
-
this.logDebug(`Generating Dependency Tree - ${this.config.label}`);
|
|
200
|
-
await this.allocateCommando(basic_1.Commando_Basic)
|
|
201
|
-
.cd(this.runtime.pathTo.pkg)
|
|
202
|
-
.append(`mkdir -p ${CONST_RunningRoot}/.trash/dependencies`)
|
|
203
|
-
.append(`pnpm list --depth 1000 > "${CONST_RunningRoot}/.trash/dependencies/${this.config.key}.txt"`)
|
|
204
|
-
.execute();
|
|
205
|
-
}
|
|
206
|
-
async checkCyclicImports() {
|
|
207
|
-
this.logDebug(`Checking Cyclic Imports - ${this.config.label}`);
|
|
208
|
-
await this.allocateCommando(basic_1.Commando_Basic)
|
|
209
|
-
.cd(this.runtime.pathTo.pkg)
|
|
210
|
-
// .setStdErrorValidator(stderr => {
|
|
211
|
-
// return !stderr.includes('Finding files') && !stderr.includes('Image created');
|
|
212
|
-
// })
|
|
213
|
-
.append(`npx madge --no-spinner --image "./imports-${this.config.key}.svg" --circular ${this.runtime.pathTo.output}`)
|
|
214
|
-
.append('echo $?')
|
|
215
|
-
.execute();
|
|
216
|
-
}
|
|
217
|
-
async lint() {
|
|
218
|
-
const pathToProjectESLint = `${RunnerParams_1.MemKey_RunnerParams.get()[RunnerParams_1.RunnerParamKey_ConfigPath]}/eslint.config.cjs`;
|
|
219
|
-
const pathToLint = `${this.runtime.pathTo.pkg}src/main`;
|
|
220
|
-
const extensions = extensionsToLint.map(ext => `--ext ${ext}`).join(' ');
|
|
221
|
-
await this.allocateCommando(nvm_1.Commando_NVM)
|
|
222
|
-
.append(`eslint --config ${pathToProjectESLint} ${extensions} ${pathToLint}`)
|
|
223
|
-
.execute();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
exports.Unit_TypescriptLib = Unit_TypescriptLib;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { UnitPhaseImplementor } from '../types';
|
|
2
|
-
import { Unit_Typescript, Unit_Typescript_Config, Unit_Typescript_RuntimeConfig } from './Unit_Typescript';
|
|
3
|
-
import { Phase_Install, Phase_Watch } from '../../phase';
|
|
4
|
-
import { StringMap } from '@nu-art/ts-common/utils/types';
|
|
5
|
-
type Unit_TypescriptProject_Config = Unit_Typescript_Config & {
|
|
6
|
-
globalPackages?: StringMap;
|
|
7
|
-
};
|
|
8
|
-
type Unit_TypescriptProject_RuntimeConfig = Unit_Typescript_RuntimeConfig & {};
|
|
9
|
-
export declare class Unit_TypescriptProject<C extends Unit_TypescriptProject_Config = Unit_TypescriptProject_Config, RTC extends Unit_TypescriptProject_RuntimeConfig = Unit_TypescriptProject_RuntimeConfig> extends Unit_Typescript<C, RTC> implements UnitPhaseImplementor<[Phase_Install, Phase_Watch]> {
|
|
10
|
-
private watchDebounce;
|
|
11
|
-
private readonly suffixesToWatch;
|
|
12
|
-
constructor(config: Unit_TypescriptProject<C>['config']);
|
|
13
|
-
private installGlobals;
|
|
14
|
-
private installPackages;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve all paths to watch in all project libs
|
|
17
|
-
* @private
|
|
18
|
-
* @returns string[]
|
|
19
|
-
*/
|
|
20
|
-
private prepareWatchPaths;
|
|
21
|
-
/**
|
|
22
|
-
* Init watch events and attach default watch callback with correct params to each of them
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
private initWatch;
|
|
26
|
-
private findUnit;
|
|
27
|
-
private watchImpl;
|
|
28
|
-
install(): Promise<void>;
|
|
29
|
-
watch(): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Unit_TypescriptProject = void 0;
|
|
27
|
-
const Unit_Typescript_1 = require("./Unit_Typescript");
|
|
28
|
-
const params_1 = require("../../../core/params/params");
|
|
29
|
-
const ts_common_1 = require("@nu-art/ts-common");
|
|
30
|
-
const consts_1 = require("../../phase-runner/consts");
|
|
31
|
-
const chokidar = __importStar(require("chokidar"));
|
|
32
|
-
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
33
|
-
const Unit_TypescriptLib_1 = require("./Unit_TypescriptLib");
|
|
34
|
-
const firebase_units_1 = require("../firebase-units");
|
|
35
|
-
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
36
|
-
const pnpm_1 = require("@nu-art/commando/shell/plugins/pnpm");
|
|
37
|
-
const pnpm_2 = require("@nu-art/commando/shell/services/pnpm");
|
|
38
|
-
class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
39
|
-
constructor(config) {
|
|
40
|
-
super(config);
|
|
41
|
-
this.suffixesToWatch = [
|
|
42
|
-
'ts',
|
|
43
|
-
'tsx',
|
|
44
|
-
'scss',
|
|
45
|
-
'json',
|
|
46
|
-
'svg'
|
|
47
|
-
];
|
|
48
|
-
this.findUnit = (pathDeclarations, currentPath) => {
|
|
49
|
-
var _a;
|
|
50
|
-
const unitToReturn = (_a = pathDeclarations.find(declaration => currentPath.startsWith(`${declaration.pathToPackage}/`))) === null || _a === void 0 ? void 0 : _a.unit;
|
|
51
|
-
if (!unitToReturn)
|
|
52
|
-
throw new ts_common_1.MUSTNeverHappenException(`current path doesnt match any declared unit, current path: ${currentPath}`);
|
|
53
|
-
return unitToReturn;
|
|
54
|
-
};
|
|
55
|
-
this.addToClassStack(Unit_TypescriptProject);
|
|
56
|
-
}
|
|
57
|
-
//######################### Internal Logic #########################
|
|
58
|
-
async installGlobals() {
|
|
59
|
-
if ((!params_1.RuntimeParams.install && !params_1.RuntimeParams.installGlobals) || !this.config.globalPackages)
|
|
60
|
-
return;
|
|
61
|
-
const packages = (0, ts_common_1._keys)(this.config.globalPackages)
|
|
62
|
-
.reduce((acc, pkg) => {
|
|
63
|
-
acc.push(`${pkg}@${this.config.globalPackages[pkg]}`);
|
|
64
|
-
return acc;
|
|
65
|
-
}, []);
|
|
66
|
-
this.logInfo(`Installing Global Packages: ${packages.join(' ')}`);
|
|
67
|
-
await this.allocateCommando(nvm_1.Commando_NVM)
|
|
68
|
-
.append(`npm i -g ${packages.join(' ')}`)
|
|
69
|
-
.execute();
|
|
70
|
-
}
|
|
71
|
-
async installPackages() {
|
|
72
|
-
if (!params_1.RuntimeParams.install && !params_1.RuntimeParams.installPackages)
|
|
73
|
-
return;
|
|
74
|
-
this.setStatus('Installing packages', 'start');
|
|
75
|
-
const runner = consts_1.MemKey_PhaseRunner.get();
|
|
76
|
-
const units = runner.getUnits().filter(unit => unit instanceof Unit_Typescript_1.Unit_Typescript);
|
|
77
|
-
const packages = units.map(unit => unit.config.pathToPackage);
|
|
78
|
-
await pnpm_2.PNPM.createWorkspace(packages);
|
|
79
|
-
await pnpm_2.PNPM.installPackages(this.allocateCommando(nvm_1.Commando_NVM, pnpm_1.Commando_PNPM));
|
|
80
|
-
this.setStatus('Installed packages', 'end');
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolve all paths to watch in all project libs
|
|
84
|
-
* @private
|
|
85
|
-
* @returns string[]
|
|
86
|
-
*/
|
|
87
|
-
prepareWatchPaths() {
|
|
88
|
-
// Using phase runner instance to resolve all project libs to watch
|
|
89
|
-
const cantBeInstanceOf = [firebase_units_1.Unit_FirebaseHostingApp, firebase_units_1.Unit_FirebaseFunctionsApp];
|
|
90
|
-
const projectLibs = consts_1.MemKey_PhaseRunner.get()
|
|
91
|
-
.getUnits()
|
|
92
|
-
.filter(unit => unit.isInstanceOf(Unit_TypescriptLib_1.Unit_TypescriptLib) && cantBeInstanceOf.every(_instance => !unit.isInstanceOf(_instance)));
|
|
93
|
-
//return all paths to watch
|
|
94
|
-
return projectLibs.map(lib => {
|
|
95
|
-
const sourceFolder = `${lib.runtime.pathTo.pkg}/src/main`;
|
|
96
|
-
return {
|
|
97
|
-
paths: this.suffixesToWatch.map(suffix => `${sourceFolder}/**/*.${suffix}`),
|
|
98
|
-
unit: lib,
|
|
99
|
-
pathToPackage: lib.runtime.pathTo.pkg
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Init watch events and attach default watch callback with correct params to each of them
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
|
-
initWatch() {
|
|
108
|
-
const pathDeclarations = this.prepareWatchPaths();
|
|
109
|
-
const paths = pathDeclarations.flatMap(path => path.paths);
|
|
110
|
-
const watcher = chokidar.watch(paths);
|
|
111
|
-
// set all events to watch and handle them
|
|
112
|
-
return new Promise((resolve, error) => {
|
|
113
|
-
this.logInfo('Starting the watcher...');
|
|
114
|
-
const units = new Set();
|
|
115
|
-
const pathsToDelete = [];
|
|
116
|
-
const onUnitChange = (path) => {
|
|
117
|
-
const unit = this.findUnit(pathDeclarations, path);
|
|
118
|
-
// @ts-ignore - FIXME: should be a better way
|
|
119
|
-
unit.setStatus('Dirty');
|
|
120
|
-
//add unit to set
|
|
121
|
-
units.add(unit);
|
|
122
|
-
return unit;
|
|
123
|
-
};
|
|
124
|
-
// set the debounce event
|
|
125
|
-
this.watchDebounce = (0, ts_common_1.queuedDebounce)(async () => {
|
|
126
|
-
const _pathsToDelete = [...pathsToDelete];
|
|
127
|
-
const unitsToCompile = Array.from(units.values());
|
|
128
|
-
// clear values in order to start collecting values for next debounce
|
|
129
|
-
(0, ts_common_1.clearArrayInstance)(pathsToDelete);
|
|
130
|
-
units.clear();
|
|
131
|
-
// fire all delete events
|
|
132
|
-
await (0, ts_common_1.Promise_all_sequentially)(_pathsToDelete.map(path => {
|
|
133
|
-
return async () => path.unit.removeSpecificFileFromDist(path.path);
|
|
134
|
-
}));
|
|
135
|
-
// fire all compile events
|
|
136
|
-
await (0, ts_common_1.Promise_all_sequentially)(unitsToCompile.map(unit => {
|
|
137
|
-
return async () => unit.watchCompile();
|
|
138
|
-
}));
|
|
139
|
-
//dispatch post debounce event to parent
|
|
140
|
-
await runner_dispatchers_1.dispatcher_UnitWatchCompile.dispatchAsync(unitsToCompile);
|
|
141
|
-
}, 2 * ts_common_1.Second, 10 * ts_common_1.Second);
|
|
142
|
-
watcher
|
|
143
|
-
.on('error', (error) => {
|
|
144
|
-
this.logError('Error while watching', error);
|
|
145
|
-
})
|
|
146
|
-
.on('ready', () => {
|
|
147
|
-
this.logInfo('Watching...');
|
|
148
|
-
runner_dispatchers_1.dispatcher_WatchReady.dispatch();
|
|
149
|
-
watcher
|
|
150
|
-
.on('add', (path) => {
|
|
151
|
-
onUnitChange(path);
|
|
152
|
-
//trigger debounce
|
|
153
|
-
this.watchDebounce();
|
|
154
|
-
})
|
|
155
|
-
.on('change', (path) => {
|
|
156
|
-
onUnitChange(path);
|
|
157
|
-
//trigger debounce
|
|
158
|
-
this.watchDebounce();
|
|
159
|
-
})
|
|
160
|
-
.on('unlinkDir', (path) => {
|
|
161
|
-
const unit = onUnitChange(path);
|
|
162
|
-
//update paths to delete
|
|
163
|
-
pathsToDelete.push({ path, unit });
|
|
164
|
-
//trigger debounce
|
|
165
|
-
this.watchDebounce();
|
|
166
|
-
})
|
|
167
|
-
.on('unlink', (path) => {
|
|
168
|
-
const unit = onUnitChange(path);
|
|
169
|
-
//update paths to delete
|
|
170
|
-
pathsToDelete.push({ path, unit });
|
|
171
|
-
//trigger debounce
|
|
172
|
-
this.watchDebounce();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
const terminatable = async () => {
|
|
176
|
-
await watcher.close();
|
|
177
|
-
this.unregisterTerminatable(terminatable);
|
|
178
|
-
};
|
|
179
|
-
this.registerTerminatable(terminatable);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
async watchImpl() {
|
|
183
|
-
await this.initWatch();
|
|
184
|
-
}
|
|
185
|
-
//######################### Phase Implementation #########################
|
|
186
|
-
async install() {
|
|
187
|
-
await this.installGlobals();
|
|
188
|
-
await this.installPackages();
|
|
189
|
-
}
|
|
190
|
-
async watch() {
|
|
191
|
-
await this.watchImpl();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
exports.Unit_TypescriptProject = Unit_TypescriptProject;
|
package/v2/unit/core/index.d.ts
DELETED
package/v2/unit/core/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./BaseUnit"), exports);
|
|
18
|
-
__exportStar(require("./Unit_Python"), exports);
|
|
19
|
-
__exportStar(require("./Unit_Typescript"), exports);
|
|
20
|
-
__exportStar(require("./Unit_TypescriptLib"), exports);
|
|
21
|
-
__exportStar(require("./Unit_TypescriptProject"), exports);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseUnit, Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../core';
|
|
2
|
-
import { UnitPhaseImplementor } from '../types';
|
|
3
|
-
import { Phase_DeployBackend, Phase_Launch, Phase_ResolveConfigs } from '../../phase';
|
|
4
|
-
import { FirebasePackageConfig } from '../../../core/types';
|
|
5
|
-
import { OnUnitWatchCompiled } from '../runner-dispatchers';
|
|
6
|
-
export type Unit_FirebaseFunctionsApp_Config = Unit_TypescriptLib_Config & {
|
|
7
|
-
firebaseConfig: FirebasePackageConfig;
|
|
8
|
-
sources?: string[];
|
|
9
|
-
};
|
|
10
|
-
export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsApp_Config = Unit_FirebaseFunctionsApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_ResolveConfigs, Phase_Launch, Phase_DeployBackend]>, OnUnitWatchCompiled {
|
|
11
|
-
static staggerCount: number;
|
|
12
|
-
readonly emulatorLogStrings: {
|
|
13
|
-
error: string[];
|
|
14
|
-
warning: string[];
|
|
15
|
-
};
|
|
16
|
-
__onUnitWatchCompiled(units: BaseUnit[]): Promise<void>;
|
|
17
|
-
constructor(config: Unit_FirebaseFunctionsApp<C>['config']);
|
|
18
|
-
protected init(setInitialized?: boolean): Promise<void>;
|
|
19
|
-
resolveConfigs(): Promise<void>;
|
|
20
|
-
compile(): Promise<void>;
|
|
21
|
-
launch(): Promise<void>;
|
|
22
|
-
deployBackend(): Promise<void>;
|
|
23
|
-
private getEnvConfig;
|
|
24
|
-
private resolveFunctionsRC;
|
|
25
|
-
private resolveProxyFile;
|
|
26
|
-
private resolveConfigDir;
|
|
27
|
-
private resolveFunctionsJSON;
|
|
28
|
-
private resolveFunctionsRuntimeConfig;
|
|
29
|
-
private createAppVersionFile;
|
|
30
|
-
private createDependenciesDir;
|
|
31
|
-
private releasePorts;
|
|
32
|
-
private runProxy;
|
|
33
|
-
private runEmulator;
|
|
34
|
-
private deployImpl;
|
|
35
|
-
}
|