@nu-art/build-and-install 0.401.4 → 0.401.6
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/package.json +5 -5
- package/phases/definitions/consts.d.ts +3 -0
- package/phases/definitions/consts.js +10 -1
- package/units/implementations/Unit_NodeProject.d.ts +1 -1
- package/units/implementations/Unit_NodeProject.js +5 -6
- package/units/implementations/Unit_PackageJson.d.ts +4 -2
- package/units/implementations/Unit_PackageJson.js +6 -0
- package/units/implementations/Unit_TypescriptLib.d.ts +2 -0
- package/units/implementations/Unit_TypescriptLib.js +8 -3
- package/units/implementations/firebase/Unit_FirebaseHostingApp.js +9 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/build-and-install",
|
|
3
|
-
"version": "0.401.
|
|
3
|
+
"version": "0.401.6",
|
|
4
4
|
"description": "A build system for monorepos that orchestrates building, testing, and deploying units with dependency-aware phase execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chokidar": "^3.6.0",
|
|
42
|
-
"@nu-art/cli-params": "0.401.
|
|
43
|
-
"@nu-art/ts-common": "0.401.
|
|
44
|
-
"@nu-art/commando": "0.401.
|
|
42
|
+
"@nu-art/cli-params": "0.401.6",
|
|
43
|
+
"@nu-art/ts-common": "0.401.6",
|
|
44
|
+
"@nu-art/commando": "0.401.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@nu-art/testalot": "0.401.
|
|
47
|
+
"@nu-art/testalot": "0.401.6"
|
|
48
48
|
},
|
|
49
49
|
"unitConfig": {
|
|
50
50
|
"type": "typescript-lib"
|
|
@@ -54,6 +54,9 @@ export declare const phase_MapExports: Phase<'mapExports'>;
|
|
|
54
54
|
export type Phase_Compile = typeof phase_Compile;
|
|
55
55
|
export declare const phaseKey_Compile = "compile";
|
|
56
56
|
export declare const phase_Compile: Phase<'compile'>;
|
|
57
|
+
export type Phase_PrepareWatch = typeof phase_PrepareWatch;
|
|
58
|
+
export declare const phaseKey_PrepareWatch = "watchPrepare";
|
|
59
|
+
export declare const phase_PrepareWatch: Phase<'watchPrepare'>;
|
|
57
60
|
export type Phase_CompileWatch = typeof phase_CompileWatch;
|
|
58
61
|
export declare const phaseKey_CompileWatch = "watchCompile";
|
|
59
62
|
export declare const phase_CompileWatch: Phase<'watchCompile'>;
|
|
@@ -38,7 +38,7 @@ export const phase_Prepare = {
|
|
|
38
38
|
name: 'Prepare',
|
|
39
39
|
method: 'prepare',
|
|
40
40
|
filter: (baiParams) => baiParams.prepare,
|
|
41
|
-
unitCategory:
|
|
41
|
+
unitCategory: 'project', // All project units need to be prepared
|
|
42
42
|
};
|
|
43
43
|
export const phaseKey_Install = 'install';
|
|
44
44
|
export const phase_Install = {
|
|
@@ -84,12 +84,21 @@ export const phase_Compile = {
|
|
|
84
84
|
filter: (baiParams) => !baiParams.noBuild,
|
|
85
85
|
dependencyPhase: [phase_PreCompile],
|
|
86
86
|
};
|
|
87
|
+
export const phaseKey_PrepareWatch = 'watchPrepare';
|
|
88
|
+
export const phase_PrepareWatch = {
|
|
89
|
+
key: phaseKey_PrepareWatch,
|
|
90
|
+
name: 'Prepare Watch',
|
|
91
|
+
method: 'watchPrepare',
|
|
92
|
+
filter: (baiParams) => baiParams.prepare,
|
|
93
|
+
unitCategory: 'project', // All project units need to be prepared
|
|
94
|
+
};
|
|
87
95
|
export const phaseKey_CompileWatch = 'watchCompile';
|
|
88
96
|
export const phase_CompileWatch = {
|
|
89
97
|
key: phaseKey_CompileWatch,
|
|
90
98
|
name: 'CompileWatch',
|
|
91
99
|
method: 'watchCompile',
|
|
92
100
|
filter: (baiParams) => !baiParams.noBuild,
|
|
101
|
+
dependencyPhase: [phase_PrepareWatch],
|
|
93
102
|
};
|
|
94
103
|
export const phaseKey_Test = 'runTests';
|
|
95
104
|
export const phase_Test = {
|
|
@@ -2,7 +2,7 @@ import { UnitPhaseImplementor } from '../../core/types.js';
|
|
|
2
2
|
import { StringMap } from '@nu-art/ts-common/utils/types';
|
|
3
3
|
import { Unit_PackageJson, Unit_PackageJson_Config } from './Unit_PackageJson.js';
|
|
4
4
|
import { ProjectUnit } from '../base/ProjectUnit.js';
|
|
5
|
-
import {
|
|
5
|
+
import { Phase_IndicesMcpServer, Phase_Install, Phase_PostPublish, Phase_Watch } from '../../phases/definitions/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Configuration for NodeProject (root project unit).
|
|
8
8
|
*/
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { _keys, arrayToMap, BadImplementationException, flatArray, lastElement, MUSTNeverHappenException, Promise_all_sequentially, queuedDebounce, Second } from '@nu-art/ts-common';
|
|
2
2
|
import * as chokidar from 'chokidar';
|
|
3
3
|
import { Unit_TypescriptLib } from './Unit_TypescriptLib.js';
|
|
4
|
-
import { Commando_NVM } from '@nu-art/commando';
|
|
5
|
-
import { Commando_PNPM } from '@nu-art/commando';
|
|
6
|
-
import { PNPM } from '@nu-art/commando';
|
|
4
|
+
import { Commando_NVM, Commando_PNPM, CommandoException, PNPM } from '@nu-art/commando';
|
|
7
5
|
import { Unit_PackageJson } from './Unit_PackageJson.js';
|
|
8
6
|
import { resolve } from 'path';
|
|
9
7
|
import { PhaseManager } from '../../phases/PhaseManager.js';
|
|
10
|
-
import { phase_CompileWatch,
|
|
8
|
+
import { phase_CompileWatch, phase_PrepareWatch } from '../../phases/definitions/index.js';
|
|
11
9
|
import { UnitsDependencyMapper } from '../../dependencies/UnitsDependencyMapper.js';
|
|
12
|
-
import { CommandoException } from '@nu-art/commando';
|
|
13
10
|
import { CONST_PNPM_LOCK, CONST_PNPM_WORKSPACE } from '../../config/consts.js';
|
|
14
11
|
import { RunningStatusHandler } from '../../runtime/RunningStatusHandler.js';
|
|
15
12
|
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
@@ -185,11 +182,13 @@ export class Unit_NodeProject extends Unit_PackageJson {
|
|
|
185
182
|
}
|
|
186
183
|
const watchRuntimeParams = {
|
|
187
184
|
...this.runtimeContext.runtimeParams,
|
|
185
|
+
watch: false,
|
|
186
|
+
prepare: true,
|
|
188
187
|
noBuild: false,
|
|
189
188
|
continue: false
|
|
190
189
|
};
|
|
191
190
|
const activeUnitKeys = this.runtimeContext.childUnits.map(unit => unit.config.key);
|
|
192
|
-
const phaseManager = new PhaseManager(new RunningStatusHandler(this.config.fullPath, watchRuntimeParams).isolate(), [[
|
|
191
|
+
const phaseManager = new PhaseManager(new RunningStatusHandler(this.config.fullPath, watchRuntimeParams).isolate(), [[phase_PrepareWatch], [phase_CompileWatch]], unitDependencyTree, activeUnitKeys, activeUnitKeys);
|
|
193
192
|
// @ts-ignore
|
|
194
193
|
phaseManager.setTag('PhaseManager-Watcher');
|
|
195
194
|
const executionPlan = await phaseManager.calculateExecutionSteps();
|
|
@@ -2,7 +2,7 @@ import { StringMap } from '@nu-art/ts-common';
|
|
|
2
2
|
import { UnitPhaseImplementor } from '../../core/types.js';
|
|
3
3
|
import { Config_ProjectUnit, ProjectUnit } from '../base/ProjectUnit.js';
|
|
4
4
|
import { TS_PackageJSON } from '../discovery/types.js';
|
|
5
|
-
import { Phase_Prepare, Phase_Purge } from '../../phases/definitions/index.js';
|
|
5
|
+
import { Phase_Prepare, Phase_PrepareWatch, Phase_Purge } from '../../phases/definitions/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Configuration for PackageJson units (units with package.json).
|
|
8
8
|
*/
|
|
@@ -30,7 +30,7 @@ export type Unit_PackageJson_Config = Config_ProjectUnit & {
|
|
|
30
30
|
*
|
|
31
31
|
* **Base For**: Unit_NodeProject, Unit_TypescriptLib, Unit_FirebaseHosting, etc.
|
|
32
32
|
*/
|
|
33
|
-
export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_PackageJson_Config> extends ProjectUnit<C> implements UnitPhaseImplementor<[Phase_Purge, Phase_Prepare]> {
|
|
33
|
+
export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_PackageJson_Config> extends ProjectUnit<C> implements UnitPhaseImplementor<[Phase_Purge, Phase_Prepare, Phase_PrepareWatch]> {
|
|
34
34
|
constructor(config: C);
|
|
35
35
|
protected npmCommand(command: string): string;
|
|
36
36
|
protected deriveDistDependencies(): StringMap;
|
|
@@ -46,6 +46,8 @@ export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_P
|
|
|
46
46
|
* **Template Params**: Includes THUNDERSTORM_VERSION, __ENV__, and child unit versions.
|
|
47
47
|
*/
|
|
48
48
|
prepare(): Promise<void>;
|
|
49
|
+
watchPrepare(): Promise<void>;
|
|
50
|
+
protected sharedPrepare(): Promise<void>;
|
|
49
51
|
/**
|
|
50
52
|
* Purges package.json and node_modules folder.
|
|
51
53
|
*
|
|
@@ -64,6 +64,12 @@ export class Unit_PackageJson extends ProjectUnit {
|
|
|
64
64
|
* **Template Params**: Includes THUNDERSTORM_VERSION, __ENV__, and child unit versions.
|
|
65
65
|
*/
|
|
66
66
|
async prepare() {
|
|
67
|
+
await this.sharedPrepare();
|
|
68
|
+
}
|
|
69
|
+
async watchPrepare() {
|
|
70
|
+
await this.sharedPrepare();
|
|
71
|
+
}
|
|
72
|
+
async sharedPrepare() {
|
|
67
73
|
const targetPath = resolve(this.config.fullPath, CONST_PackageJSON);
|
|
68
74
|
const params = this.deriveLibDependencies();
|
|
69
75
|
const packageJson = FileSystemUtils.file.template.transform(__stringify(this.config.packageJson, true), params);
|
|
@@ -50,6 +50,8 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
|
|
|
50
50
|
protected clearOutputDir(): Promise<void>;
|
|
51
51
|
protected clearOutputDirImpl(): Promise<void>;
|
|
52
52
|
prepare(): Promise<void>;
|
|
53
|
+
watchPrepare(): Promise<void>;
|
|
54
|
+
protected sharedPrepare(): Promise<void>;
|
|
53
55
|
protected compileImpl(): Promise<void>;
|
|
54
56
|
protected copyAssetsToOutput(): Promise<void>;
|
|
55
57
|
ignoreWatchFiles(): string[];
|
|
@@ -2,9 +2,7 @@ import * as fs from 'fs';
|
|
|
2
2
|
import { copyFileSync, existsSync, promises as _fs, readdirSync, statSync } from 'fs';
|
|
3
3
|
import { __stringify, arrayToMap, BadImplementationException, ImplementationMissingException, LogLevel, merge, NotImplementedYetException } from '@nu-art/ts-common';
|
|
4
4
|
import { CONST_BaiConfig, CONST_FirebaseJSON, CONST_FirebaseRC, CONST_PackageJSON, CONST_PackageJSONTemplate, CONST_TS_CONFIG } from '../../config/consts.js';
|
|
5
|
-
import { CommandoException } from '@nu-art/commando';
|
|
6
|
-
import { Commando_NVM } from '@nu-art/commando';
|
|
7
|
-
import { Commando_Basic } from '@nu-art/commando';
|
|
5
|
+
import { Commando_Basic, Commando_NVM, CommandoException } from '@nu-art/commando';
|
|
8
6
|
import { resolve, resolve as pathResolve } from 'path';
|
|
9
7
|
import { Unit_PackageJson } from './Unit_PackageJson.js';
|
|
10
8
|
import { glob } from 'node:fs/promises';
|
|
@@ -184,6 +182,13 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
184
182
|
}
|
|
185
183
|
async prepare() {
|
|
186
184
|
await super.prepare();
|
|
185
|
+
await this.sharedPrepare();
|
|
186
|
+
}
|
|
187
|
+
async watchPrepare() {
|
|
188
|
+
await super.watchPrepare();
|
|
189
|
+
await this.sharedPrepare();
|
|
190
|
+
}
|
|
191
|
+
async sharedPrepare() {
|
|
187
192
|
await FileSystemUtils.folder.create(this.config.output);
|
|
188
193
|
if (this.config.packageJson.private) {
|
|
189
194
|
// @ts-ignore
|
|
@@ -193,22 +193,15 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
193
193
|
await FileSystemUtils.folder.delete(stagingDir);
|
|
194
194
|
await FileSystemUtils.folder.create(stagingDir);
|
|
195
195
|
const tarballPath = resolve(buildOutputDir, CONST_HostingBuildTarball);
|
|
196
|
-
// Ensure firebase.json and .firebaserc exist (they should from prepare phase)
|
|
197
|
-
await this.resolveHostingRC();
|
|
198
|
-
await this.resolveHostingJSON();
|
|
199
196
|
// Copy all files to staging directory
|
|
200
|
-
const firebaseJsonPath = resolve(this.config.fullPath, CONST_FirebaseJSON);
|
|
201
|
-
const firebaseRcPath = resolve(this.config.fullPath, CONST_FirebaseRC);
|
|
202
197
|
const outputDirName = resolve(this.config.output).split('/').pop() || 'dist';
|
|
203
198
|
// Copy firebase.json, .firebaserc, dist folder, and create deployment-metadata.json
|
|
204
|
-
await FileSystemUtils.file.copy(firebaseJsonPath, resolve(stagingDir, CONST_FirebaseJSON));
|
|
205
|
-
await FileSystemUtils.file.copy(firebaseRcPath, resolve(stagingDir, CONST_FirebaseRC));
|
|
206
199
|
await FileSystemUtils.folder.copy(this.config.output, resolve(stagingDir, outputDirName));
|
|
207
200
|
await FileSystemUtils.file.write.json(resolve(stagingDir, CONST_DeploymentMetadata), metadata);
|
|
208
201
|
// Create tarball from staging directory contents
|
|
209
202
|
// Note: Use explicit file list to include hidden files (.*) which * wildcard doesn't match
|
|
210
203
|
commando.cd(stagingDir);
|
|
211
|
-
await this.executeAsyncCommando(commando, `tar -czf ${tarballPath} ${
|
|
204
|
+
await this.executeAsyncCommando(commando, `tar -czf ${tarballPath} ${CONST_DeploymentMetadata} ${outputDirName}`, (stdout, stderr, exitCode) => {
|
|
212
205
|
if (exitCode !== 0)
|
|
213
206
|
throw new CommandoException(`Failed to create tarball (exit code ${exitCode})`, stdout, stderr, exitCode);
|
|
214
207
|
});
|
|
@@ -289,19 +282,25 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
289
282
|
this.logInfo(`Locating downloaded tarball...`);
|
|
290
283
|
const downloadedFiles = await FileSystemUtils.folder.list(deployTempDir);
|
|
291
284
|
const tarballFile = downloadedFiles.find(file => file.endsWith('.tar.gz'));
|
|
292
|
-
if (!tarballFile)
|
|
285
|
+
if (!tarballFile)
|
|
293
286
|
throw new ImplementationMissingException(`Downloaded tarball not found in ${deployTempDir}. Files found: ${downloadedFiles.join(', ')}`);
|
|
294
|
-
}
|
|
295
287
|
const tarballPath = resolve(deployTempDir, tarballFile);
|
|
296
288
|
this.logDebug(`Downloaded tarball: ${tarballPath}`);
|
|
297
289
|
// Extract tarball directly to deployTempDir (contains firebase.json, .firebaserc, and dist/)
|
|
298
290
|
this.logInfo(`Extracting hosting package...`);
|
|
291
|
+
this.logInfo(`Extracting hosting package...`);
|
|
299
292
|
await this.executeAsyncCommando(commando, `tar -xzf ${tarballPath} -C ${deployTempDir}`, (stdout, stderr, exitCode) => {
|
|
300
293
|
if (exitCode !== 0) {
|
|
301
294
|
throw new CommandoException(`Failed to extract tarball (exit code ${exitCode})`, stdout, stderr, exitCode);
|
|
302
295
|
}
|
|
303
296
|
});
|
|
304
297
|
this.logInfo(`Extracted hosting package to: ${deployTempDir}`);
|
|
298
|
+
this.logInfo(`Copying firebase configs..`);
|
|
299
|
+
const firebaseJsonPath = resolve(this.config.fullPath, CONST_FirebaseJSON);
|
|
300
|
+
const firebaseRcPath = resolve(this.config.fullPath, CONST_FirebaseRC);
|
|
301
|
+
await FileSystemUtils.file.copy(firebaseJsonPath, resolve(deployTempDir, CONST_FirebaseJSON));
|
|
302
|
+
await FileSystemUtils.file.copy(firebaseRcPath, resolve(deployTempDir, CONST_FirebaseRC));
|
|
303
|
+
this.logDebug(`Copied firebase configs!`);
|
|
305
304
|
// firebase.json and .firebaserc are already in deployTempDir from tarball extraction
|
|
306
305
|
// Deploy using firebase CLI
|
|
307
306
|
const envConfig = this.getEnvConfig();
|