@nu-art/build-and-install 0.400.8 → 0.400.10
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 +3 -3
- package/v3/units/Unit_PackageJson.d.ts +1 -0
- package/v3/units/Unit_PackageJson.js +3 -0
- package/v3/units/Unit_TypescriptLib.d.ts +3 -2
- package/v3/units/Unit_TypescriptLib.js +22 -13
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +1 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +8 -6
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +2 -2
- package/v3/units/index.d.ts +1 -0
- package/v3/units/index.js +1 -0
- package/v3/units/types.d.ts +41 -0
- package/v3/units/types.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/build-and-install",
|
|
3
|
-
"version": "0.400.
|
|
3
|
+
"version": "0.400.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"chokidar": "^3.6.0",
|
|
34
|
-
"@nu-art/ts-common": "0.400.
|
|
35
|
-
"@nu-art/commando": "0.400.
|
|
34
|
+
"@nu-art/ts-common": "0.400.10",
|
|
35
|
+
"@nu-art/commando": "0.400.10"
|
|
36
36
|
},
|
|
37
37
|
"unitConfig": {
|
|
38
38
|
"type": "typescript-lib"
|
|
@@ -8,6 +8,7 @@ export type Unit_PackageJson_Config = Config_ProjectUnit & {
|
|
|
8
8
|
};
|
|
9
9
|
export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_PackageJson_Config> extends ProjectUnit<C> implements UnitPhaseImplementor<[Phase_Purge, Phase_Prepare]> {
|
|
10
10
|
constructor(config: C);
|
|
11
|
+
protected npmCommand(command: string): string;
|
|
11
12
|
protected deriveDistDependencies(): StringMap;
|
|
12
13
|
protected deriveLibDependencies(): StringMap;
|
|
13
14
|
prepare(): Promise<void>;
|
|
@@ -10,6 +10,9 @@ export class Unit_PackageJson extends ProjectUnit {
|
|
|
10
10
|
this.addToClassStack(Unit_PackageJson);
|
|
11
11
|
}
|
|
12
12
|
//######################### Internal Logic #########################
|
|
13
|
+
npmCommand(command) {
|
|
14
|
+
return resolve(this.runtimeContext.parentUnit.config.fullPath, './node_modules/.bin', command);
|
|
15
|
+
}
|
|
13
16
|
deriveDistDependencies() {
|
|
14
17
|
const params = this.runtimeContext.childUnits.reduce((dependencies, unit) => {
|
|
15
18
|
dependencies[unit.config.key] = unit.config.packageJson.version;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TypedMap } from '@nu-art/ts-common';
|
|
1
|
+
import { RecursivePartial, TypedMap } from '@nu-art/ts-common';
|
|
2
2
|
import { UnitPhaseImplementor } from '../core/types.js';
|
|
3
3
|
import { Unit_PackageJson, Unit_PackageJson_Config } from './Unit_PackageJson.js';
|
|
4
4
|
import { Phase_CheckCyclicImports, Phase_Compile, Phase_Lint, Phase_PreCompile, Phase_PrintDependencyTree, Phase_Publish, Phase_Test, Phase_ToESM } from '../phase/index.js';
|
|
5
|
+
import { TsConfig } from './types.js';
|
|
5
6
|
export type Unit_TypescriptLib_Config = Unit_PackageJson_Config & {
|
|
6
7
|
customESLintConfig: boolean;
|
|
7
8
|
customTSConfig: boolean;
|
|
@@ -40,7 +41,7 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
|
|
|
40
41
|
lint(): Promise<void>;
|
|
41
42
|
private resolveESLintConfig;
|
|
42
43
|
protected deriveTSConfigPaths(): TypedMap<string[]>;
|
|
43
|
-
protected resolveTSConfig(srcFolder: string, sourceFolderType: string): Promise<void>;
|
|
44
|
+
protected resolveTSConfig(srcFolder: string, sourceFolderType: string, tsConfigOverride?: RecursivePartial<TsConfig>): Promise<void>;
|
|
44
45
|
publish(): Promise<void>;
|
|
45
46
|
convertToESM(): Promise<void>;
|
|
46
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import { copyFileSync, existsSync, promises as _fs, readdirSync, statSync } from 'fs';
|
|
3
|
-
import { __stringify, arrayToMap, BadImplementationException, ImplementationMissingException, LogLevel, NotImplementedYetException } from '@nu-art/ts-common';
|
|
4
|
-
import { CONST_BaiConfig, CONST_FirebaseJSON, CONST_FirebaseRC,
|
|
3
|
+
import { __stringify, arrayToMap, BadImplementationException, ImplementationMissingException, LogLevel, merge, NotImplementedYetException } from '@nu-art/ts-common';
|
|
4
|
+
import { CONST_BaiConfig, CONST_FirebaseJSON, CONST_FirebaseRC, CONST_PackageJSON, CONST_PackageJSONTemplate, CONST_TS_CONFIG } from '../../core/consts.js';
|
|
5
5
|
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
6
6
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
7
7
|
import { Commando_Basic } from '@nu-art/commando/shell/plugins/basic';
|
|
@@ -160,8 +160,7 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
160
160
|
return LogLevel.Error;
|
|
161
161
|
})
|
|
162
162
|
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
|
|
163
|
-
|
|
164
|
-
await this.executeAsyncCommando(commando, `${command} -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.config.output}"`, (stdout, stderr, exitCode) => {
|
|
163
|
+
await this.executeAsyncCommando(commando, `${this.npmCommand('tsc')} -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.config.output}"`, (stdout, stderr, exitCode) => {
|
|
165
164
|
if (stderr.length)
|
|
166
165
|
this.logError(stderr);
|
|
167
166
|
if (exitCode > 0)
|
|
@@ -329,7 +328,7 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
329
328
|
return dependencies;
|
|
330
329
|
}, {});
|
|
331
330
|
}
|
|
332
|
-
async resolveTSConfig(srcFolder, sourceFolderType) {
|
|
331
|
+
async resolveTSConfig(srcFolder, sourceFolderType, tsConfigOverride) {
|
|
333
332
|
const entryPath = pathResolve(srcFolder, sourceFolderType);
|
|
334
333
|
if (!statSync(entryPath).isDirectory()) {
|
|
335
334
|
return this.logError(`Unexpected non-directory entry in src/: ${sourceFolderType}`);
|
|
@@ -344,15 +343,25 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
344
343
|
// const defaultTsConfigTemplate = pathResolve(baiDefaultsPath, `tsconfig-${entry}.json`);
|
|
345
344
|
const projectDefaultTsConfig = pathResolve(this.runtimeContext.parentUnit.config.fullPath, this.runtimeContext.baiConfig.files?.typescript?.tsConfig?.[sourceFolderType] ?? `tsconfig-${sourceFolderType}.json`);
|
|
346
345
|
if (existsSync(projectDefaultTsConfig)) {
|
|
347
|
-
this.logDebug(`
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
346
|
+
this.logDebug(`Reading and merging project-level default tsconfig for source: ${sourceFolderType}`);
|
|
347
|
+
// Read the template JSON file
|
|
348
|
+
const templateConfig = await FileSystemUtils.file.read.json(projectDefaultTsConfig);
|
|
349
|
+
// Build the override config with conditional sourceMap settings
|
|
350
|
+
const overrideConfig = {
|
|
351
|
+
...tsConfigOverride,
|
|
352
|
+
compilerOptions: {
|
|
353
|
+
...tsConfigOverride?.compilerOptions,
|
|
354
|
+
...(this.runtimeContext.runtimeParams.publish ? {} : {
|
|
355
|
+
sourceMap: true,
|
|
356
|
+
sourceRoot: entryPath
|
|
357
|
+
})
|
|
358
|
+
}
|
|
354
359
|
};
|
|
355
|
-
|
|
360
|
+
// Merge template with override
|
|
361
|
+
const mergedConfig = merge(templateConfig, overrideConfig);
|
|
362
|
+
// Write the merged config
|
|
363
|
+
await FileSystemUtils.file.write.json(tsConfigPath, mergedConfig);
|
|
364
|
+
return;
|
|
356
365
|
}
|
|
357
366
|
// if (existsSync(defaultTsConfigTemplate)) {
|
|
358
367
|
// this.logDebug(`Copying default tsconfig for source: ${entry}`);
|
|
@@ -43,6 +43,7 @@ export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsA
|
|
|
43
43
|
protected copyPackageJSONToOutput(): Promise<void>;
|
|
44
44
|
prepare(): Promise<void>;
|
|
45
45
|
resolveConfigs(): Promise<void>;
|
|
46
|
+
compile(): Promise<void>;
|
|
46
47
|
postCompile(): Promise<void>;
|
|
47
48
|
launch(): Promise<void>;
|
|
48
49
|
releaseEmulatorPorts(): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONST_FirebaseJSON, CONST_FirebaseRC,
|
|
1
|
+
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_PackageJSON, CONST_VersionApp } from '../../../core/consts.js';
|
|
2
2
|
import { __stringify, _keys, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, Second, sleep } from '@nu-art/ts-common';
|
|
3
3
|
import { Const_FirebaseConfigKeys, Const_FirebaseDefaultsKeyToFile } from '../../../defaults/consts.js';
|
|
4
4
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
@@ -79,8 +79,11 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
79
79
|
await this.resolveFunctionsRuntimeConfig();
|
|
80
80
|
await this.resolveFunctionsJSON();
|
|
81
81
|
}
|
|
82
|
-
async
|
|
82
|
+
async compile() {
|
|
83
83
|
await this.createAppVersionFile();
|
|
84
|
+
await super.compile();
|
|
85
|
+
}
|
|
86
|
+
async postCompile() {
|
|
84
87
|
await this.createDependenciesDir();
|
|
85
88
|
}
|
|
86
89
|
async launch() {
|
|
@@ -108,7 +111,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
108
111
|
this.functions[match[1]] = match[2];
|
|
109
112
|
});
|
|
110
113
|
const debug = this.runtimeContext.runtimeParams.verbose ? ' --debug' : '';
|
|
111
|
-
await this.executeAsyncCommando(commando,
|
|
114
|
+
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')}${debug} deploy --only functions --force`, (stdout, stderr, exitCode) => {
|
|
112
115
|
if (exitCode === 0)
|
|
113
116
|
return;
|
|
114
117
|
throw new CommandoException(`Failed to deploy function with exit code ${exitCode}`, stdout, stderr, exitCode);
|
|
@@ -275,8 +278,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
275
278
|
await this.resolveProxyFile();
|
|
276
279
|
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
277
280
|
.cd(this.config.fullPath);
|
|
278
|
-
|
|
279
|
-
await this.executeAsyncCommando(commando, `${command} src/main/proxy.ts`);
|
|
281
|
+
await this.executeAsyncCommando(commando, `${this.npmCommand('tsx')} src/main/proxy.ts`);
|
|
280
282
|
this.logWarning('PROXY TERMINATED');
|
|
281
283
|
}
|
|
282
284
|
async runEmulator() {
|
|
@@ -290,7 +292,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
290
292
|
return LogLevel.Warning;
|
|
291
293
|
})
|
|
292
294
|
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'));
|
|
293
|
-
await this.executeAsyncCommando(commando,
|
|
295
|
+
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')} emulators:start --project ${this.config.envConfig.projectId} --export-on-exit --import=${this.config.pathToEmulatorData} ${this.runtimeContext.runtimeParams.debugBackend
|
|
294
296
|
? `--inspect-functions ${this.config.debugPort}` : ''}`);
|
|
295
297
|
this.logWarning('EMULATORS TERMINATED');
|
|
296
298
|
}
|
|
@@ -25,7 +25,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
25
25
|
await this.resolveHostingRuntimeConfig();
|
|
26
26
|
}
|
|
27
27
|
async compile() {
|
|
28
|
-
await this.resolveTSConfig(resolve(this.config.fullPath, './src'), 'main');
|
|
28
|
+
await this.resolveTSConfig(resolve(this.config.fullPath, './src'), 'main', { compilerOptions: { declaration: false } });
|
|
29
29
|
await this.clearOutputDir();
|
|
30
30
|
await this.createAppVersionFile();
|
|
31
31
|
await this.compileImpl();
|
|
@@ -47,7 +47,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
47
47
|
this.hosting[match[1]] = match[2];
|
|
48
48
|
});
|
|
49
49
|
const debug = this.runtimeContext.runtimeParams.verbose ? ' --debug' : '';
|
|
50
|
-
await this.executeAsyncCommando(commando,
|
|
50
|
+
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')}${debug} deploy --only hosting`);
|
|
51
51
|
}
|
|
52
52
|
//######################### ResolveConfig Logic #########################
|
|
53
53
|
getEnvConfig() {
|
package/v3/units/index.d.ts
CHANGED
package/v3/units/index.js
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript compiler options type based on tsconfig.json schema
|
|
4
|
+
*/
|
|
5
|
+
export type TsConfigCompilerOptions = {
|
|
6
|
+
module?: string;
|
|
7
|
+
moduleResolution?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
jsx?: string;
|
|
10
|
+
allowJs?: boolean;
|
|
11
|
+
lib?: string[];
|
|
12
|
+
noEmit?: boolean;
|
|
13
|
+
sourceMap?: boolean;
|
|
14
|
+
sourceRoot?: string;
|
|
15
|
+
declaration?: boolean;
|
|
16
|
+
resolveJsonModule?: boolean;
|
|
17
|
+
esModuleInterop?: boolean;
|
|
18
|
+
experimentalDecorators?: boolean;
|
|
19
|
+
allowSyntheticDefaultImports?: boolean;
|
|
20
|
+
noUnusedLocals?: boolean;
|
|
21
|
+
strict?: boolean;
|
|
22
|
+
paths?: TypedMap<string[]>;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
rootDir?: string;
|
|
25
|
+
outDir?: string;
|
|
26
|
+
include?: string[];
|
|
27
|
+
exclude?: string[];
|
|
28
|
+
extends?: string;
|
|
29
|
+
compilerOptions?: TsConfigCompilerOptions;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Full TypeScript configuration type
|
|
34
|
+
*/
|
|
35
|
+
export type TsConfig = {
|
|
36
|
+
compilerOptions?: TsConfigCompilerOptions;
|
|
37
|
+
include?: string[];
|
|
38
|
+
exclude?: string[];
|
|
39
|
+
extends?: string;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|