@nu-art/build-and-install 0.400.3 → 0.400.4
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.js +1 -1
- package/core/params/params.d.ts +3 -2
- package/core/params/params.js +18 -8
- package/package.json +3 -3
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js +1 -1
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +1 -1
- package/v3/core/Unit_HelpPrinter.d.ts +1 -1
- package/v3/phase/consts.d.ts +3 -3
- package/v3/phase/consts.js +8 -8
- package/v3/units/Unit_NodeProject.js +1 -1
- package/v3/units/Unit_PackageJson.js +1 -1
- package/v3/units/Unit_TypescriptLib.d.ts +3 -3
- package/v3/units/Unit_TypescriptLib.js +139 -19
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +1 -1
- package/v3/core/FileSystemUtils.d.ts +0 -34
- package/v3/core/FileSystemUtils.js +0 -151
package/build-and-install-v3.js
CHANGED
|
@@ -9,10 +9,10 @@ import { PhaseManager } from './v3/PhaseManager.js';
|
|
|
9
9
|
import { Unit_NodeProject } from './v3/units/index.js';
|
|
10
10
|
import { resolve } from 'path';
|
|
11
11
|
import { CONST_BaiConfig, CONST_NodeModules } from './core/consts.js';
|
|
12
|
-
import { FileSystemUtils } from './v3/core/FileSystemUtils.js';
|
|
13
12
|
import { UnitMapper_FirebaseFunction, UnitMapper_FirebaseHosting, UnitMapper_NodeLib, UnitMapper_NodeProject } from './v3/UnitsMapper/resolvers/index.js';
|
|
14
13
|
import { CLIParamsResolver } from '@nu-art/commando/cli-params/CLIParamsResolver';
|
|
15
14
|
import { RunningStatusHandler } from './v3/RunningStatusHandler.js';
|
|
15
|
+
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
16
16
|
export const DefaultPhases = [
|
|
17
17
|
...phases_Build,
|
|
18
18
|
...phases_Launch,
|
package/core/params/params.d.ts
CHANGED
|
@@ -32,8 +32,9 @@ export declare const BaiParam_Verbose: BaseCliParam<'verbose', boolean>;
|
|
|
32
32
|
export declare const BaiParam_QuickDeploy: BaseCliParam<'quickDeploy', boolean>;
|
|
33
33
|
type PromoteType = 'patch' | 'minor' | 'major';
|
|
34
34
|
export declare const BaiParam_Publish: BaseCliParam<'publish', PromoteType>;
|
|
35
|
-
export declare const BaiParam_PublishDryRun: BaseCliParam<'publishDryRun', boolean>;
|
|
36
35
|
export declare const BaiParam_UsePackage: BaseCliParam<'usePackage', string[]>;
|
|
37
|
-
export declare const
|
|
36
|
+
export declare const BaiParam_ToESM: BaseCliParam<'toESM', boolean>;
|
|
37
|
+
export declare const BaiParam_Simulate: BaseCliParam<'simulation', boolean>;
|
|
38
|
+
export declare const AllBaiParams: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", PromoteType> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean>)[];
|
|
38
39
|
export type BaiParams = CliParams<typeof AllBaiParams>;
|
|
39
40
|
export {};
|
package/core/params/params.js
CHANGED
|
@@ -226,13 +226,6 @@ export const BaiParam_Publish = {
|
|
|
226
226
|
description: 'Will publish to NPM any package that is not marked as private in its __package.json \nenum options: patch | minor | major \nDefault Param: patch',
|
|
227
227
|
process: (part) => part ?? 'patch'
|
|
228
228
|
};
|
|
229
|
-
export const BaiParam_PublishDryRun = {
|
|
230
|
-
keys: ['--publish-dry-run'],
|
|
231
|
-
keyName: 'publishDryRun',
|
|
232
|
-
type: 'boolean',
|
|
233
|
-
group: 'Other',
|
|
234
|
-
description: 'Will pack and prepare a package for publish, but will NOT publish to NPM any package',
|
|
235
|
-
};
|
|
236
229
|
export const BaiParam_UsePackage = {
|
|
237
230
|
keys: ['-up', '--use-packages'],
|
|
238
231
|
keyName: 'usePackage',
|
|
@@ -246,6 +239,22 @@ export const BaiParam_UsePackage = {
|
|
|
246
239
|
},
|
|
247
240
|
dependencies: [{ param: BaiParam_AllUnits, value: true }]
|
|
248
241
|
};
|
|
242
|
+
export const BaiParam_ToESM = {
|
|
243
|
+
keys: ['-tesm', '--to-esm'],
|
|
244
|
+
keyName: 'toESM',
|
|
245
|
+
type: 'boolean',
|
|
246
|
+
group: 'Other',
|
|
247
|
+
description: 'Will migrate existing CJS code to ESM',
|
|
248
|
+
dependencies: [{ param: BaiParam_AllUnits, value: true }]
|
|
249
|
+
};
|
|
250
|
+
export const BaiParam_Simulate = {
|
|
251
|
+
keys: ['--simulate', '-sim'],
|
|
252
|
+
keyName: 'simulation',
|
|
253
|
+
type: 'boolean',
|
|
254
|
+
group: 'Other',
|
|
255
|
+
description: 'In combination with other params, will not perform the outbound operation, but instead simulate it',
|
|
256
|
+
dependencies: [{ param: BaiParam_AllUnits, value: true }]
|
|
257
|
+
};
|
|
249
258
|
export const AllBaiParams = [
|
|
250
259
|
BaiParam_AllUnits,
|
|
251
260
|
BaiParam_DependencyTree,
|
|
@@ -274,8 +283,9 @@ export const AllBaiParams = [
|
|
|
274
283
|
BaiParam_DebugBackend,
|
|
275
284
|
BaiParam_Debug,
|
|
276
285
|
BaiParam_Verbose,
|
|
277
|
-
BaiParam_PublishDryRun,
|
|
278
286
|
BaiParam_Publish,
|
|
279
287
|
BaiParam_UsePackage,
|
|
288
|
+
BaiParam_ToESM,
|
|
289
|
+
BaiParam_Simulate,
|
|
280
290
|
BaiParam_DebugLifecycle
|
|
281
291
|
];
|
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.4",
|
|
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.4",
|
|
35
|
+
"@nu-art/commando": "0.400.4"
|
|
36
36
|
},
|
|
37
37
|
"unitConfig": {
|
|
38
38
|
"type": "typescript-lib"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __stringify, _keys, _values, BadImplementationException, DateTimeFormat_yyyyMMDDTHHmmss, deepClone, Logger, reduceObject, sortArray } from '@nu-art/ts-common';
|
|
2
|
-
import { FileSystemUtils } from '
|
|
2
|
+
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
/**
|
|
5
5
|
* Maps unit dependencies and provides tools to analyze and operate on the dependency graph.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _keys, deepClone, tsValidate, tsValidateBoolean, tsValidateOptionalAnyString, tsValidateResult } from '@nu-art/ts-common';
|
|
2
2
|
import { FilesCache } from '../../core/FilesCache.js';
|
|
3
3
|
import { UnitMapper_Base } from './UnitMapper_Base.js';
|
|
4
|
-
import { FileSystemUtils } from '
|
|
4
|
+
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
5
5
|
export class UnitMapper_Node extends UnitMapper_Base {
|
|
6
6
|
static invalidPaths = [];
|
|
7
7
|
static tsValidator_Node = {
|
|
@@ -3,7 +3,7 @@ import { UnitPhaseImplementor } from './types.js';
|
|
|
3
3
|
import { Phase } from '../phase/index.js';
|
|
4
4
|
import { ProjectUnit } from '../units/index.js';
|
|
5
5
|
export declare const BaiParam_Help: BaseCliParam<'help', boolean>;
|
|
6
|
-
declare const AllBaiParams_Help: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", "patch" | "minor" | "major"> | BaseCliParam<"
|
|
6
|
+
declare const AllBaiParams_Help: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", "patch" | "minor" | "major"> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean> | BaseCliParam<"help", boolean>)[];
|
|
7
7
|
export type Help_BaiParams = CliParams<typeof AllBaiParams_Help>;
|
|
8
8
|
export type Phase_Help = typeof phase_Help;
|
|
9
9
|
export declare const phaseKey_Help = "help";
|
package/v3/phase/consts.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare const phase_PrintDependencyTree: Phase<'printDependencyTree'>;
|
|
|
5
5
|
export type Phase_CheckCyclicImports = typeof phase_CheckCyclicImports;
|
|
6
6
|
export declare const phaseKey_CheckCyclicImports = "check-cyclic-imports";
|
|
7
7
|
export declare const phase_CheckCyclicImports: Phase<'checkCyclicImports'>;
|
|
8
|
+
export type Phase_ToESM = typeof phase_ToESM;
|
|
9
|
+
export declare const phaseKey_ToESM = "convertToESM";
|
|
10
|
+
export declare const phase_ToESM: Phase<'convertToESM'>;
|
|
8
11
|
export type Phase_Purge = typeof phase_Purge;
|
|
9
12
|
export declare const phaseKey_Purge = "purge";
|
|
10
13
|
export declare const phase_Purge: Phase<'purge'>;
|
|
@@ -37,9 +40,6 @@ export type Phase_Launch = typeof phase_Launch;
|
|
|
37
40
|
export declare const phaseKey_Launch = "launch";
|
|
38
41
|
export declare const phase_Launch: Phase<'launch'>;
|
|
39
42
|
export declare const phases_Launch: Phase<string>[][];
|
|
40
|
-
export type Phase_PublishDryRun = typeof phase_PublishDryRun;
|
|
41
|
-
export declare const phaseKey_PublishDryRun = "publishDryRun";
|
|
42
|
-
export declare const phase_PublishDryRun: Phase<'publishDryRun'>;
|
|
43
43
|
export type Phase_Publish = typeof phase_Publish;
|
|
44
44
|
export declare const phaseKey_Publish = "publish";
|
|
45
45
|
export declare const phase_Publish: Phase<'publish'>;
|
package/v3/phase/consts.js
CHANGED
|
@@ -14,6 +14,13 @@ export const phase_CheckCyclicImports = {
|
|
|
14
14
|
filter: (baiParams) => baiParams.checkCyclicImports,
|
|
15
15
|
terminateAfterPhase: true,
|
|
16
16
|
};
|
|
17
|
+
export const phaseKey_ToESM = 'convertToESM';
|
|
18
|
+
export const phase_ToESM = {
|
|
19
|
+
key: phaseKey_ToESM,
|
|
20
|
+
name: 'ToESM',
|
|
21
|
+
method: 'convertToESM',
|
|
22
|
+
filter: (baiParams) => !baiParams.noBuild,
|
|
23
|
+
};
|
|
17
24
|
export const phaseKey_Purge = 'purge';
|
|
18
25
|
export const phase_Purge = {
|
|
19
26
|
key: phaseKey_Purge,
|
|
@@ -95,13 +102,6 @@ export const phase_Launch = {
|
|
|
95
102
|
export const phases_Launch = [[
|
|
96
103
|
phase_Launch,
|
|
97
104
|
]];
|
|
98
|
-
export const phaseKey_PublishDryRun = 'publishDryRun';
|
|
99
|
-
export const phase_PublishDryRun = {
|
|
100
|
-
key: phaseKey_PublishDryRun,
|
|
101
|
-
name: 'PublishDryRun',
|
|
102
|
-
method: 'publishDryRun',
|
|
103
|
-
filter: (baiParams) => baiParams.publishDryRun,
|
|
104
|
-
};
|
|
105
105
|
export const phaseKey_Publish = 'publish';
|
|
106
106
|
export const phase_Publish = {
|
|
107
107
|
key: phaseKey_Publish,
|
|
@@ -123,4 +123,4 @@ export const phase_Deploy = {
|
|
|
123
123
|
method: 'deploy',
|
|
124
124
|
filter: (baiParams) => !!baiParams.deploy,
|
|
125
125
|
};
|
|
126
|
-
export const phases_Deploy = [[
|
|
126
|
+
export const phases_Deploy = [[phase_Publish, phase_Deploy], [phase_PostPublish]];
|
|
@@ -6,13 +6,13 @@ import { Commando_PNPM } from '@nu-art/commando/shell/plugins/pnpm';
|
|
|
6
6
|
import { PNPM } from '@nu-art/commando/shell/services/pnpm';
|
|
7
7
|
import { Unit_PackageJson } from './Unit_PackageJson.js';
|
|
8
8
|
import { resolve } from 'path';
|
|
9
|
-
import { FileSystemUtils } from '../core/FileSystemUtils.js';
|
|
10
9
|
import { PhaseManager } from '../PhaseManager.js';
|
|
11
10
|
import { phase_CompileWatch } from '../phase/index.js';
|
|
12
11
|
import { UnitsDependencyMapper } from '../UnitsDependencyMapper/UnitsDependencyMapper.js';
|
|
13
12
|
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
14
13
|
import { CONST_PNPM_LOCK, CONST_PNPM_WORKSPACE } from '../../core/consts.js';
|
|
15
14
|
import { RunningStatusHandler } from '../RunningStatusHandler.js';
|
|
15
|
+
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
16
16
|
export class Unit_NodeProject extends Unit_PackageJson {
|
|
17
17
|
watcher;
|
|
18
18
|
innerUnits = [];
|
|
@@ -2,8 +2,8 @@ import { CONST_NodeModules, CONST_PackageJSON } from '../../core/consts.js';
|
|
|
2
2
|
import { __stringify } from '@nu-art/ts-common';
|
|
3
3
|
import { ProjectUnit } from './ProjectUnit.js';
|
|
4
4
|
import { resolve } from 'path';
|
|
5
|
-
import { DEFAULT_OLD_TEMPLATE_PATTERN, FileSystemUtils } from '../core/FileSystemUtils.js';
|
|
6
5
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
6
|
+
import { DEFAULT_OLD_TEMPLATE_PATTERN, FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
7
7
|
export class Unit_PackageJson extends ProjectUnit {
|
|
8
8
|
constructor(config) {
|
|
9
9
|
super(config);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { 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
|
-
import { Phase_CheckCyclicImports, Phase_Compile, Phase_Lint, Phase_PreCompile, Phase_PrintDependencyTree, Phase_Publish,
|
|
4
|
+
import { Phase_CheckCyclicImports, Phase_Compile, Phase_Lint, Phase_PreCompile, Phase_PrintDependencyTree, Phase_Publish, Phase_Test, Phase_ToESM } from '../phase/index.js';
|
|
5
5
|
export type Unit_TypescriptLib_Config = Unit_PackageJson_Config & {
|
|
6
6
|
customESLintConfig: boolean;
|
|
7
7
|
customTSConfig: boolean;
|
|
8
8
|
hasSelfHotReload: boolean;
|
|
9
9
|
output: string;
|
|
10
10
|
};
|
|
11
|
-
export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Unit_TypescriptLib_Config> extends Unit_PackageJson<C> implements UnitPhaseImplementor<[Phase_PreCompile, Phase_Compile, Phase_PrintDependencyTree, Phase_CheckCyclicImports, Phase_Lint, Phase_Test, Phase_Publish,
|
|
11
|
+
export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Unit_TypescriptLib_Config> extends Unit_PackageJson<C> implements UnitPhaseImplementor<[Phase_PreCompile, Phase_Compile, Phase_PrintDependencyTree, Phase_CheckCyclicImports, Phase_Lint, Phase_Test, Phase_Publish, Phase_ToESM]> {
|
|
12
12
|
private TestTypeWorkspaceSetup;
|
|
13
13
|
runTests(): Promise<void>;
|
|
14
14
|
constructor(config: Unit_TypescriptLib<C>['config']);
|
|
@@ -40,6 +40,6 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
|
|
|
40
40
|
private resolveESLintConfig;
|
|
41
41
|
protected deriveTSConfigPaths(): TypedMap<string[]>;
|
|
42
42
|
protected resolveTSConfig(srcFolder: string, sourceFolderType: string): Promise<void>;
|
|
43
|
-
publishDryRun(): Promise<void>;
|
|
44
43
|
publish(): Promise<void>;
|
|
44
|
+
convertToESM(): Promise<void>;
|
|
45
45
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import { copyFileSync, existsSync, promises as _fs, readdirSync, statSync } from 'fs';
|
|
3
|
-
import { __stringify, BadImplementationException, ImplementationMissingException, LogLevel, NotImplementedYetException } from '@nu-art/ts-common';
|
|
4
|
-
import { CONST_BaiConfig, CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, CONST_PackageJSON, CONST_TS_CONFIG } from '../../core/consts.js';
|
|
3
|
+
import { __stringify, arrayToMap, BadImplementationException, exists, ImplementationMissingException, LogLevel, NotImplementedYetException } from '@nu-art/ts-common';
|
|
4
|
+
import { CONST_BaiConfig, CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, 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';
|
|
8
8
|
import { resolve, resolve as pathResolve } from 'path';
|
|
9
9
|
import { Unit_PackageJson } from './Unit_PackageJson.js';
|
|
10
|
-
import { DEFAULT_OLD_TEMPLATE_PATTERN, DEFAULT_TEMPLATE_PATTERN, FileSystemUtils } from '../core/FileSystemUtils.js';
|
|
11
10
|
import { glob } from 'node:fs/promises';
|
|
12
11
|
import { TestTypes } from '../../core/params/params.js';
|
|
12
|
+
import { DEFAULT_OLD_TEMPLATE_PATTERN, DEFAULT_TEMPLATE_PATTERN, FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
13
|
+
import path from 'node:path';
|
|
13
14
|
const assetExtensions = [
|
|
14
15
|
'json',
|
|
15
16
|
'scss',
|
|
@@ -145,8 +146,6 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
145
146
|
if (this.config.packageJson.private) {
|
|
146
147
|
// @ts-ignore
|
|
147
148
|
this.publish = undefined;
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
this.publishDryRun = undefined;
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
151
|
async compileImpl() {
|
|
@@ -355,27 +354,148 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
355
354
|
this.logError(`Missing tsconfig templates for source folder: ${sourceFolderType}`);
|
|
356
355
|
throw new ImplementationMissingException(`Missing tsconfig template for source folder: ${sourceFolderType}`);
|
|
357
356
|
}
|
|
358
|
-
async publishDryRun() {
|
|
359
|
-
if (this.config.packageJson.private)
|
|
360
|
-
return this.logWarning(`Not publishing a private package`);
|
|
361
|
-
this.logDebug(`Creating NPM Package`);
|
|
362
|
-
await this.allocateCommando(Commando_Basic)
|
|
363
|
-
.cd(this.config.output)
|
|
364
|
-
.append('npm pack --pack-destination ./..')
|
|
365
|
-
.execute();
|
|
366
|
-
this.logDebug(`Publishing Dry Run`);
|
|
367
|
-
await this.allocateCommando(Commando_Basic)
|
|
368
|
-
.cd(this.config.output)
|
|
369
|
-
.append('npm publish --dry-run')
|
|
370
|
-
.execute();
|
|
371
|
-
}
|
|
372
357
|
async publish() {
|
|
373
358
|
if (this.config.packageJson.private)
|
|
374
359
|
return this.logInfo(`Not publishing a private package`);
|
|
360
|
+
if (this.runtimeContext.runtimeParams.simulation) {
|
|
361
|
+
this.logWarning(` ===> Publish Simulation -STARTED <=== `);
|
|
362
|
+
this.logDebug(`Creating NPM Package`);
|
|
363
|
+
await this.allocateCommando(Commando_Basic)
|
|
364
|
+
.cd(this.config.output)
|
|
365
|
+
.append('npm pack --pack-destination ./..')
|
|
366
|
+
.execute();
|
|
367
|
+
this.logDebug(`Publishing Dry Run`);
|
|
368
|
+
await this.allocateCommando(Commando_Basic)
|
|
369
|
+
.cd(this.config.output)
|
|
370
|
+
.append('npm publish --dry-run')
|
|
371
|
+
.execute();
|
|
372
|
+
this.logWarning(` ===> Publish Simulation - ENDED <=== `);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
375
|
this.logDebug(`Publishing Package - For REAL`);
|
|
376
376
|
await this.allocateCommando(Commando_Basic)
|
|
377
377
|
.cd(this.config.output)
|
|
378
378
|
.append('npm publish --access public')
|
|
379
379
|
.execute();
|
|
380
380
|
}
|
|
381
|
+
async convertToESM() {
|
|
382
|
+
const ignore = ['node_modules', '.git', 'dist', '.gitignore', 'build'];
|
|
383
|
+
const specificFiles = [CONST_PackageJSONTemplate];
|
|
384
|
+
const fileExtensions = ['.ts', '.tsx', '.mts', '.js', '.jsx', '.mjs'];
|
|
385
|
+
const units = arrayToMap(this.runtimeContext.childUnits, unit => unit.config.key);
|
|
386
|
+
const toESM = async (pathTofile, importPath) => {
|
|
387
|
+
importPath = importPath.replace(/\/+/g, '/');
|
|
388
|
+
if (importPath.endsWith('.js'))
|
|
389
|
+
return importPath;
|
|
390
|
+
for (const extension of fileExtensions) {
|
|
391
|
+
if (!importPath.endsWith(extension))
|
|
392
|
+
continue;
|
|
393
|
+
importPath = importPath.replace(extension, '');
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
let initialPath;
|
|
397
|
+
let relativePathToFile;
|
|
398
|
+
let extension = '';
|
|
399
|
+
if (importPath.startsWith('.') || importPath.startsWith('/')) {
|
|
400
|
+
initialPath = path.dirname(pathTofile);
|
|
401
|
+
relativePathToFile = importPath;
|
|
402
|
+
extension = '.js';
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
const [part1, part2, ...relativePathParts] = importPath.split('/');
|
|
406
|
+
const unit = units[part1] ?? units[`${part1}/${part2}`];
|
|
407
|
+
if (unit) {
|
|
408
|
+
initialPath = `${unit.config.fullPath}/src/main`;
|
|
409
|
+
relativePathToFile = relativePathParts.join('/');
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (!exists(initialPath) || !exists(relativePathToFile))
|
|
413
|
+
return importPath;
|
|
414
|
+
const fullPath = path.resolve(initialPath, relativePathToFile);
|
|
415
|
+
if (await FileSystemUtils.exists(fullPath) && await FileSystemUtils.folder.isFolder(fullPath))
|
|
416
|
+
relativePathToFile = `${relativePathToFile}/index`;
|
|
417
|
+
// throw new BadImplementationException(`Expected file to exist: ${fullPath}`);
|
|
418
|
+
relativePathToFile += extension;
|
|
419
|
+
relativePathToFile = relativePathToFile.replace(/\/+/g, '/');
|
|
420
|
+
return relativePathToFile;
|
|
421
|
+
};
|
|
422
|
+
const importMatchers = [
|
|
423
|
+
{
|
|
424
|
+
regex: /from\s+["']([^"']+)["']/g,
|
|
425
|
+
replacer: async (pathTofile, importPath) => `from "${await toESM(pathTofile, importPath)}"`
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
regex: /require\(\s*["']([^"']+)["']\s*\)/g,
|
|
429
|
+
replacer: async (pathTofile, importPath) => `await import("${await toESM(pathTofile, importPath)}")`
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
regex: /import\(\s*["']([^"']+)["']\s*\)/g,
|
|
433
|
+
replacer: async (pathTofile, importPath) => `import("${await toESM(pathTofile, importPath)}")`
|
|
434
|
+
},
|
|
435
|
+
];
|
|
436
|
+
const updateImports = async (pathToEntry) => {
|
|
437
|
+
let content = await FileSystemUtils.file.read(pathToEntry);
|
|
438
|
+
this.logDebug('Processing file: ', pathToEntry);
|
|
439
|
+
for (const { regex, replacer } of importMatchers) {
|
|
440
|
+
const matches = [];
|
|
441
|
+
let match;
|
|
442
|
+
regex.lastIndex = 0;
|
|
443
|
+
while ((match = regex.exec(content))) {
|
|
444
|
+
matches.push({ original: match[0], path: match[1], index: match.index });
|
|
445
|
+
regex.lastIndex = match.index + match[0].length;
|
|
446
|
+
}
|
|
447
|
+
for (const { original, path } of matches) {
|
|
448
|
+
const replacement = await replacer(pathToEntry, path);
|
|
449
|
+
// Replace all exact original strings globally
|
|
450
|
+
content = content.split(original).join(replacement);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (!this.runtimeContext.runtimeParams.simulation)
|
|
454
|
+
await FileSystemUtils.file.write(pathToEntry, content);
|
|
455
|
+
};
|
|
456
|
+
const migratePackageJSON = async (pathToEntry) => {
|
|
457
|
+
const packageJson = JSON.parse(await FileSystemUtils.file.read(pathToEntry));
|
|
458
|
+
if (!packageJson.name.startsWith('@nu-art/'))
|
|
459
|
+
packageJson.private = packageJson.private ?? true;
|
|
460
|
+
packageJson.type = packageJson.type ?? 'module';
|
|
461
|
+
packageJson.exports = packageJson.exports ?? {
|
|
462
|
+
'.': {
|
|
463
|
+
'types': './index.d.ts',
|
|
464
|
+
'import': './index.js'
|
|
465
|
+
},
|
|
466
|
+
'./*': {
|
|
467
|
+
'types': './*.d.ts',
|
|
468
|
+
'import': './*.js'
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
if (!this.runtimeContext.runtimeParams.simulation)
|
|
472
|
+
await FileSystemUtils.file.write(pathToEntry, __stringify(packageJson, true));
|
|
473
|
+
};
|
|
474
|
+
await FileSystemUtils.folder.iterate(this.config.fullPath, {
|
|
475
|
+
filter: async (pathToEntry) => {
|
|
476
|
+
const name = path.basename(pathToEntry);
|
|
477
|
+
if (ignore.includes(name))
|
|
478
|
+
return false;
|
|
479
|
+
if (await FileSystemUtils.folder.isFolder(pathToEntry))
|
|
480
|
+
return true;
|
|
481
|
+
if (!await FileSystemUtils.file.isFile(pathToEntry)) {
|
|
482
|
+
this.logWarning(`NOT a file or folder: ${pathToEntry}`);
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
if (specificFiles.includes(name))
|
|
486
|
+
return true;
|
|
487
|
+
const fileExtension = path.extname(pathToEntry);
|
|
488
|
+
return fileExtensions.includes(fileExtension.toLowerCase());
|
|
489
|
+
},
|
|
490
|
+
processor: async (pathToEntry) => {
|
|
491
|
+
const name = path.basename(pathToEntry);
|
|
492
|
+
const fileExtension = path.extname(pathToEntry);
|
|
493
|
+
if (name === CONST_PackageJSONTemplate)
|
|
494
|
+
return await migratePackageJSON(pathToEntry);
|
|
495
|
+
if (fileExtensions.includes(fileExtension.toLowerCase()))
|
|
496
|
+
return await updateImports(pathToEntry);
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
;
|
|
381
501
|
}
|
|
@@ -4,8 +4,8 @@ import { promises as _fs } from 'fs';
|
|
|
4
4
|
import { __stringify, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, reduceObject, Second, sleep } from '@nu-art/ts-common';
|
|
5
5
|
import { Const_FirebaseConfigKeys, Const_FirebaseDefaultsKeyToFile } from '../../../defaults/consts.js';
|
|
6
6
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
7
|
-
import { DEFAULT_OLD_TEMPLATE_PATTERN, FileSystemUtils } from '../../core/FileSystemUtils.js';
|
|
8
7
|
import { resolve } from 'path';
|
|
8
|
+
import { DEFAULT_OLD_TEMPLATE_PATTERN, FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
9
9
|
export const firebaseFunctionEmulator_ErrorStrings = [
|
|
10
10
|
'functions: Failed',
|
|
11
11
|
];
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { StringMap } from '@nu-art/ts-common';
|
|
2
|
-
export declare const DEFAULT_TEMPLATE_PATTERN: RegExp;
|
|
3
|
-
export declare const DEFAULT_OLD_TEMPLATE_PATTERN: RegExp;
|
|
4
|
-
export declare const FileSystemUtils: {
|
|
5
|
-
file: {
|
|
6
|
-
exists: (pathToFile: string) => Promise<boolean>;
|
|
7
|
-
delete: (pathToFile: string, mustExist?: boolean) => Promise<void>;
|
|
8
|
-
write: (pathToFile: string, content: string) => Promise<void>;
|
|
9
|
-
read: (pathToFile: string) => Promise<string>;
|
|
10
|
-
copy: (sourcePath: string, targetPath: string) => Promise<void>;
|
|
11
|
-
template: {
|
|
12
|
-
read: (pathToFile: string, params: StringMap, pattern?: RegExp) => Promise<string>;
|
|
13
|
-
transform: (input: string, params: StringMap, pattern?: RegExp) => string;
|
|
14
|
-
write: (pathToFile: string, content: string, params: StringMap, pattern?: RegExp) => Promise<void>;
|
|
15
|
-
copy: (sourcePath: string, targetPath: string, params: StringMap, pattern?: RegExp) => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
folder: {
|
|
19
|
-
delete: (pathToFolder: string, mustExist?: boolean) => Promise<void>;
|
|
20
|
-
empty: (pathToFolder: string, mustExist?: boolean) => Promise<void>;
|
|
21
|
-
create: (pathToFolder: string) => Promise<string | void>;
|
|
22
|
-
list: ((pathToFolder: string) => Promise<string[]>) & {
|
|
23
|
-
forEach: ((pathToFolder: string, callback: (path: string) => Promise<any>) => Promise<void>) & {
|
|
24
|
-
file: (pathToFolder: string, callback: (path: string) => Promise<any>) => Promise<void>;
|
|
25
|
-
folder: (pathToFolder: string, callback: (path: string) => Promise<any>) => Promise<void>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
symlink: {
|
|
30
|
-
create: (targetPath: string, linkPath: string) => Promise<void>;
|
|
31
|
-
delete: (pathToLink: string, mustExist?: boolean) => Promise<void>;
|
|
32
|
-
read: (pathToLink: string) => Promise<string>;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { promises as _fs } from 'fs';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import { BadImplementationException, exists } from '@nu-art/ts-common';
|
|
4
|
-
async function isFile(path) {
|
|
5
|
-
return (await _fs.stat(path)).isFile();
|
|
6
|
-
}
|
|
7
|
-
async function isFolder(path) {
|
|
8
|
-
return (await _fs.stat(path)).isDirectory();
|
|
9
|
-
}
|
|
10
|
-
async function assertFile(path) {
|
|
11
|
-
if (!(await isFile(path)))
|
|
12
|
-
throw new BadImplementationException(`Expected file but found directory or non-file: ${path}`);
|
|
13
|
-
}
|
|
14
|
-
async function assertFolder(path) {
|
|
15
|
-
if (!(await isFolder(path)))
|
|
16
|
-
throw new BadImplementationException(`Expected folder but found file or non-directory: ${path}`);
|
|
17
|
-
}
|
|
18
|
-
async function fileExists(path) {
|
|
19
|
-
try {
|
|
20
|
-
await _fs.access(path);
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function assertExists(path, mustExist, type) {
|
|
28
|
-
const doesExist = await fileExists(path);
|
|
29
|
-
if (!doesExist) {
|
|
30
|
-
if (mustExist)
|
|
31
|
-
throw new BadImplementationException(`${type} does not exist: ${path}`);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
const escapeRegExp = (string) => string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
37
|
-
export const DEFAULT_TEMPLATE_PATTERN = new RegExp(`\{\{(\\S*?)\}\}`);
|
|
38
|
-
export const DEFAULT_OLD_TEMPLATE_PATTERN = new RegExp(`(?<!\\\\)\\$([a-zA-Z]\\w{2,})`);
|
|
39
|
-
export const FileSystemUtils = {
|
|
40
|
-
file: {
|
|
41
|
-
exists: async (pathToFile) => {
|
|
42
|
-
return await fileExists(pathToFile);
|
|
43
|
-
},
|
|
44
|
-
delete: async (pathToFile, mustExist = false) => {
|
|
45
|
-
if (!await assertExists(pathToFile, mustExist, 'File'))
|
|
46
|
-
return;
|
|
47
|
-
await assertFile(pathToFile);
|
|
48
|
-
return _fs.rm(pathToFile);
|
|
49
|
-
},
|
|
50
|
-
write: async (pathToFile, content) => {
|
|
51
|
-
await FileSystemUtils.folder.create(resolve(pathToFile, '..'));
|
|
52
|
-
return _fs.writeFile(pathToFile, content, 'utf-8');
|
|
53
|
-
},
|
|
54
|
-
read: async (pathToFile) => {
|
|
55
|
-
await assertFile(pathToFile);
|
|
56
|
-
return _fs.readFile(pathToFile, 'utf-8');
|
|
57
|
-
},
|
|
58
|
-
copy: async (sourcePath, targetPath) => {
|
|
59
|
-
await assertExists(targetPath, false, 'File');
|
|
60
|
-
await assertFile(sourcePath);
|
|
61
|
-
await FileSystemUtils.folder.create(resolve(targetPath, '..'));
|
|
62
|
-
return _fs.copyFile(sourcePath, targetPath);
|
|
63
|
-
},
|
|
64
|
-
template: {
|
|
65
|
-
read: async (pathToFile, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
66
|
-
const content = await FileSystemUtils.file.read(pathToFile);
|
|
67
|
-
return FileSystemUtils.file.template.transform(content, params, pattern);
|
|
68
|
-
},
|
|
69
|
-
transform: (input, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
70
|
-
let match;
|
|
71
|
-
while (match = input.match(pattern)) {
|
|
72
|
-
const value = params[match[1]];
|
|
73
|
-
if (!exists(value))
|
|
74
|
-
throw new BadImplementationException(`Missing template param: ${match[1]}`);
|
|
75
|
-
const fullMatchRegex = new RegExp(escapeRegExp(match[0]), 'g');
|
|
76
|
-
input = input.replace(fullMatchRegex, value);
|
|
77
|
-
}
|
|
78
|
-
return input;
|
|
79
|
-
},
|
|
80
|
-
write: async (pathToFile, content, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
81
|
-
const transformedContent = FileSystemUtils.file.template.transform(content, params, pattern);
|
|
82
|
-
return FileSystemUtils.file.write(pathToFile, transformedContent);
|
|
83
|
-
},
|
|
84
|
-
copy: async (sourcePath, targetPath, params, pattern = DEFAULT_TEMPLATE_PATTERN) => {
|
|
85
|
-
const content = await FileSystemUtils.file.read(sourcePath);
|
|
86
|
-
const transformedContent = FileSystemUtils.file.template.transform(content, params, pattern);
|
|
87
|
-
return FileSystemUtils.file.write(targetPath, transformedContent);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
folder: {
|
|
92
|
-
delete: async (pathToFolder, mustExist = false) => {
|
|
93
|
-
if (!await assertExists(pathToFolder, mustExist, 'Folder'))
|
|
94
|
-
return;
|
|
95
|
-
await assertFolder(pathToFolder);
|
|
96
|
-
return _fs.rm(pathToFolder, { recursive: true, force: true });
|
|
97
|
-
},
|
|
98
|
-
empty: async (pathToFolder, mustExist = true) => {
|
|
99
|
-
if (!await assertExists(pathToFolder, mustExist, 'Folder'))
|
|
100
|
-
return;
|
|
101
|
-
await assertFolder(pathToFolder);
|
|
102
|
-
const entries = await _fs.readdir(pathToFolder);
|
|
103
|
-
await Promise.all(entries.map(entry => _fs.rm(resolve(pathToFolder, entry), { recursive: true, force: true })));
|
|
104
|
-
},
|
|
105
|
-
create: async (pathToFolder) => {
|
|
106
|
-
if (await fileExists(pathToFolder))
|
|
107
|
-
return assertFolder(pathToFolder);
|
|
108
|
-
return _fs.mkdir(pathToFolder, { recursive: true });
|
|
109
|
-
},
|
|
110
|
-
list: Object.assign(async (pathToFolder) => {
|
|
111
|
-
return await _fs.readdir(pathToFolder);
|
|
112
|
-
}, {
|
|
113
|
-
forEach: Object.assign(async (pathToFolder, callback) => {
|
|
114
|
-
const entries = await _fs.readdir(pathToFolder);
|
|
115
|
-
for (const entry of entries)
|
|
116
|
-
await callback(resolve(pathToFolder, entry));
|
|
117
|
-
}, {
|
|
118
|
-
file: async (pathToFolder, callback) => {
|
|
119
|
-
await FileSystemUtils.folder.list.forEach(pathToFolder, async (entry) => {
|
|
120
|
-
if (!await isFile(entry))
|
|
121
|
-
return;
|
|
122
|
-
await callback(entry);
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
folder: async (pathToFolder, callback) => {
|
|
126
|
-
await FileSystemUtils.folder.list.forEach(pathToFolder, async (entry) => {
|
|
127
|
-
if (!await isFolder(entry))
|
|
128
|
-
return;
|
|
129
|
-
await callback(entry);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
symlink: {
|
|
136
|
-
create: async (targetPath, linkPath) => {
|
|
137
|
-
return _fs.symlink(targetPath, linkPath);
|
|
138
|
-
},
|
|
139
|
-
delete: async (pathToLink, mustExist = false) => {
|
|
140
|
-
if (!await assertExists(pathToLink, mustExist, 'Symlink'))
|
|
141
|
-
return;
|
|
142
|
-
const stat = await _fs.lstat(pathToLink);
|
|
143
|
-
if (!stat.isSymbolicLink())
|
|
144
|
-
throw new BadImplementationException(`Expected symlink but found something else: ${pathToLink}`);
|
|
145
|
-
return _fs.unlink(pathToLink);
|
|
146
|
-
},
|
|
147
|
-
read: async (pathToLink) => {
|
|
148
|
-
return _fs.readlink(pathToLink);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|