@genesislcap/build-kit 14.162.4-alpha-ea9526e.0 → 14.162.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/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/prompts.js +2 -2
- package/dist/utils/seed.processing.d.ts.map +1 -1
- package/dist/utils/seed.processing.js +3 -4
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/types/build-context.ts +57 -0
- package/src/types/config.ts +269 -0
- package/src/types/index.ts +3 -0
- package/src/types/pwa.ts +67 -0
- package/src/utils/archive.ts +18 -0
- package/src/utils/args.ts +7 -0
- package/src/utils/build-context.ts +42 -0
- package/src/utils/child-process.ts +115 -0
- package/src/utils/config.ts +45 -0
- package/src/utils/console.ts +1 -0
- package/src/utils/env.ts +71 -0
- package/src/utils/federation.ts +40 -0
- package/src/utils/fs.ts +53 -0
- package/src/utils/handlebars.ts +61 -0
- package/src/utils/https.ts +29 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/json.ts +12 -0
- package/src/utils/npm.ts +155 -0
- package/src/utils/object.ts +21 -0
- package/src/utils/prompts.ts +160 -0
- package/src/utils/proxy.ts +139 -0
- package/src/utils/seed.fetching.ts +257 -0
- package/src/utils/seed.meta.ts +34 -0
- package/src/utils/seed.processing.ts +100 -0
- package/src/utils/seed.setup.ts +101 -0
- package/src/utils/time.ts +1 -0
- package/test/utils/args.test.ts +17 -0
- package/test/utils/build-context.test.ts +68 -0
- package/test/utils/env.test.ts +212 -0
- package/test/utils/handlebars.test.ts +277 -0
- package/test/utils/https.test.ts +14 -0
- package/test/utils/proxy.test.ts +96 -0
- package/test/utils/seed.fetching.test.ts +145 -0
- package/test/utils/seed.meta.test.ts +33 -0
- package/tsconfig.json +18 -0
- package/dist/utils/seed.commands.d.ts +0 -19
- package/dist/utils/seed.commands.d.ts.map +0 -1
- package/dist/utils/seed.commands.js +0 -58
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
3
|
+
import { getSeedDirs, resolveGitSeed, resolveNPMSeed } from '../../src/utils';
|
|
4
|
+
|
|
5
|
+
const suite = createLogicSuite('resolveGitSeed');
|
|
6
|
+
|
|
7
|
+
const scenarios = [
|
|
8
|
+
{
|
|
9
|
+
description: 'defaulting',
|
|
10
|
+
args: [],
|
|
11
|
+
expected: {
|
|
12
|
+
repo: 'genesiscommunitysuccess/blank-app-seed',
|
|
13
|
+
ref: 'main',
|
|
14
|
+
id: `gh:genesiscommunitysuccess/blank-app-seed#main`,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: 'git user defaulting',
|
|
19
|
+
args: ['positions-app-seed'],
|
|
20
|
+
expected: {
|
|
21
|
+
repo: 'genesiscommunitysuccess/positions-app-seed',
|
|
22
|
+
ref: 'main',
|
|
23
|
+
id: `gh:genesiscommunitysuccess/positions-app-seed#main`,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
description: 'custom ref',
|
|
28
|
+
args: ['positions-app-seed', 'mytag'],
|
|
29
|
+
expected: {
|
|
30
|
+
repo: 'genesiscommunitysuccess/positions-app-seed',
|
|
31
|
+
ref: 'mytag',
|
|
32
|
+
id: `gh:genesiscommunitysuccess/positions-app-seed#mytag`,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
description: 'custom ref',
|
|
37
|
+
args: ['positions-app-seed', 'mytag', 'subfolder'],
|
|
38
|
+
expected: {
|
|
39
|
+
repo: 'genesiscommunitysuccess/positions-app-seed',
|
|
40
|
+
ref: 'mytag',
|
|
41
|
+
id: `gh:genesiscommunitysuccess/positions-app-seed/subfolder#mytag`,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
description: 'custom provider',
|
|
46
|
+
args: ['positions-app-seed', 'mytag', 'subfolder', 'bitbucket'],
|
|
47
|
+
expected: {
|
|
48
|
+
repo: 'genesiscommunitysuccess/positions-app-seed',
|
|
49
|
+
ref: 'mytag',
|
|
50
|
+
id: `bitbucket:genesiscommunitysuccess/positions-app-seed/subfolder#mytag`,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
scenarios.forEach((scenario) => {
|
|
56
|
+
suite(scenario.description, () => {
|
|
57
|
+
assert.equal(resolveGitSeed(...scenario.args), scenario.expected);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
suite.run();
|
|
62
|
+
|
|
63
|
+
const suite2 = createLogicSuite('resolveNPMSeed');
|
|
64
|
+
|
|
65
|
+
const scenarios2 = [
|
|
66
|
+
{
|
|
67
|
+
description: 'defaulting',
|
|
68
|
+
args: [],
|
|
69
|
+
expected: {
|
|
70
|
+
artifact: 'genesislcap/blank-app-seed',
|
|
71
|
+
ref: 'latest',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
description: 'custom seed',
|
|
76
|
+
args: ['positions-app-seed'],
|
|
77
|
+
expected: {
|
|
78
|
+
artifact: 'genesislcap/positions-app-seed',
|
|
79
|
+
ref: 'latest',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
description: 'custom ref',
|
|
84
|
+
args: ['positions-app-seed', 'prerelease'],
|
|
85
|
+
expected: {
|
|
86
|
+
artifact: 'genesislcap/positions-app-seed',
|
|
87
|
+
ref: 'prerelease',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
description: 'no scope',
|
|
92
|
+
args: ['my-seed', 'prerelease', 'false'],
|
|
93
|
+
expected: {
|
|
94
|
+
artifact: 'my-seed',
|
|
95
|
+
ref: 'prerelease',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
scenarios2.forEach((scenario) => {
|
|
101
|
+
suite(scenario.description, () => {
|
|
102
|
+
assert.equal(resolveNPMSeed(...scenario.args), scenario.expected);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
suite2.run();
|
|
107
|
+
|
|
108
|
+
const suite3 = createLogicSuite('getSeedDirs');
|
|
109
|
+
|
|
110
|
+
suite3('loading remote seed - init', async () => {
|
|
111
|
+
const dir = 'myapp';
|
|
112
|
+
const isInit = true;
|
|
113
|
+
const remote = true;
|
|
114
|
+
const result = getSeedDirs('blank-app-seed', dir, '', isInit, remote);
|
|
115
|
+
const genxDir = relative(process.cwd(), `${dir}/.genx`);
|
|
116
|
+
assert.equal(result, {
|
|
117
|
+
localPath: 'blank-app-seed',
|
|
118
|
+
dir,
|
|
119
|
+
subdir: '',
|
|
120
|
+
isLocalSeed: false,
|
|
121
|
+
genxDir,
|
|
122
|
+
extractedSeedDir: dir,
|
|
123
|
+
extractedSeedGenxDir: genxDir,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
suite3('loading remote seed - add', async () => {
|
|
128
|
+
const dir = 'myapp';
|
|
129
|
+
const isInit = false;
|
|
130
|
+
const remote = true;
|
|
131
|
+
const result = getSeedDirs('blank-app-seed', dir, '', isInit, remote);
|
|
132
|
+
const genxDir = relative(process.cwd(), `${dir}/.genx`);
|
|
133
|
+
const extractedSeedGenxDir = relative(process.cwd(), `${dir}/.genx/tmp/.genx`);
|
|
134
|
+
assert.equal(result, {
|
|
135
|
+
localPath: 'blank-app-seed',
|
|
136
|
+
dir,
|
|
137
|
+
subdir: '',
|
|
138
|
+
isLocalSeed: false,
|
|
139
|
+
genxDir,
|
|
140
|
+
extractedSeedDir: `${dir}/.genx/tmp`,
|
|
141
|
+
extractedSeedGenxDir,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
suite3.run();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
2
|
+
import { loadGenxModule, loadSeed } from '../../src/utils';
|
|
3
|
+
|
|
4
|
+
const suite = createLogicSuite('loadSeed');
|
|
5
|
+
|
|
6
|
+
suite('loading local seed', async () => {
|
|
7
|
+
const result = await loadSeed('./test/fixtures/mock-seed/.genx');
|
|
8
|
+
assert.type(result.configure, 'function');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
suite.run();
|
|
12
|
+
|
|
13
|
+
const suite2 = createLogicSuite('loadGenxModule');
|
|
14
|
+
|
|
15
|
+
suite2('loading local seed', async () => {
|
|
16
|
+
const result = await loadGenxModule('./test/fixtures/mock-seed/.genx');
|
|
17
|
+
assert.equal(result, {
|
|
18
|
+
name: 'mock-seed',
|
|
19
|
+
description: 'Mock Seed',
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
license: 'Apache-2.0',
|
|
22
|
+
genxSeedConfig: {
|
|
23
|
+
processFiles: {
|
|
24
|
+
interpolateVariables: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
include: ['.kt', '.md'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
suite2.run();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declarationDir": "./dist",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2015",
|
|
7
|
+
"ES2016",
|
|
8
|
+
"ES2017",
|
|
9
|
+
"ES2019",
|
|
10
|
+
],
|
|
11
|
+
"module": "commonjs",
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"rootDir": "./src",
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src/**/*"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { COMMAND } from '../types';
|
|
2
|
-
export type SeedCommandOptions = {
|
|
3
|
-
insecure?: boolean;
|
|
4
|
-
seed?: string;
|
|
5
|
-
subdir?: string;
|
|
6
|
-
remote?: boolean;
|
|
7
|
-
ref?: string;
|
|
8
|
-
skipOptionalPrompts?: boolean;
|
|
9
|
-
isLogLevelVerbose?: boolean;
|
|
10
|
-
shell?: boolean;
|
|
11
|
-
scope?: boolean;
|
|
12
|
-
npm?: boolean;
|
|
13
|
-
skipInitDirCheck?: boolean;
|
|
14
|
-
params?: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare const runSeedCommand: (dirpath: string, options: SeedCommandOptions, command?: COMMAND) => Promise<void>;
|
|
19
|
-
//# sourceMappingURL=seed.commands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seed.commands.d.ts","sourceRoot":"","sources":["../../src/utils/seed.commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOnC,MAAM,MAAM,kBAAkB,GAAG;IAE/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAInB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAI5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,MAAM,CAAC,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,MAAM,WACN,kBAAkB,YAClB,OAAO,kBAmEjB,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runSeedCommand = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const consola_1 = require("consola");
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
const child_process_1 = require("./child-process");
|
|
10
|
-
const console_1 = require("./console");
|
|
11
|
-
const seed_fetching_1 = require("./seed.fetching");
|
|
12
|
-
const seed_meta_1 = require("./seed.meta");
|
|
13
|
-
const seed_setup_1 = require("./seed.setup");
|
|
14
|
-
const runSeedCommand = (dirpath, options, command = types_1.COMMAND.INIT) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const dir = (0, node_path_1.resolve)(process.cwd(), dirpath);
|
|
16
|
-
const start = Date.now();
|
|
17
|
-
consola_1.consola.debug('CLI options', { dir, options, command });
|
|
18
|
-
const isInit = command === types_1.COMMAND.INIT;
|
|
19
|
-
const { insecure, seed, subdir, remote, ref, skipOptionalPrompts, params, isLogLevelVerbose, shell, scope, npm, skipInitDirCheck, } = options;
|
|
20
|
-
if (isLogLevelVerbose) {
|
|
21
|
-
// Enables debug output in giget
|
|
22
|
-
process.env.DEBUG = '1';
|
|
23
|
-
// Debug level https://github.com/unjs/consola#log-level
|
|
24
|
-
process.env.CONSOLA_LEVEL = '4';
|
|
25
|
-
consola_1.consola.level = 4;
|
|
26
|
-
}
|
|
27
|
-
// don't overwrite if exists
|
|
28
|
-
if (isInit && (0, node_fs_1.existsSync)(dir) && !skipInitDirCheck) {
|
|
29
|
-
consola_1.consola.error(`Target directory ${(0, console_1.bold)(dir)} already exists.`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
// for add operation there is no default seed - it needs to be specified explicitly
|
|
33
|
-
if (!isInit && !seed) {
|
|
34
|
-
consola_1.consola.error(`Please specify a seed.`);
|
|
35
|
-
process.exit();
|
|
36
|
-
}
|
|
37
|
-
// fetch remote or copy local seed
|
|
38
|
-
const result = yield (0, seed_fetching_1.fetchSeed)(seed, dir, remote, ref, insecure, subdir, isInit, npm, scope);
|
|
39
|
-
consola_1.consola.debug('Seed fetched', result);
|
|
40
|
-
// NPM install in .genx folder
|
|
41
|
-
yield (0, seed_setup_1.installSeedDeps)(result.extractedSeedGenxDir, isLogLevelVerbose);
|
|
42
|
-
const seedInfo = yield (0, seed_meta_1.loadSeed)(result.extractedSeedGenxDir);
|
|
43
|
-
consola_1.consola.debug('Seed loaded', seedInfo);
|
|
44
|
-
// run seed configure script
|
|
45
|
-
yield (0, seed_setup_1.configureSeedApp)(seedInfo, result, params, dir, skipOptionalPrompts, isInit);
|
|
46
|
-
const label = isInit ? 'created' : 'updated';
|
|
47
|
-
consola_1.consola.success(`Project successfully ${label} in ${Date.now() - start}ms.`);
|
|
48
|
-
// show next steps message if defined in seed details
|
|
49
|
-
const nextStepsMessage = seedInfo.details.nextStepsMessage;
|
|
50
|
-
if (nextStepsMessage === null || nextStepsMessage === void 0 ? void 0 : nextStepsMessage.length) {
|
|
51
|
-
consola_1.consola.info(`Next steps: \n` + nextStepsMessage);
|
|
52
|
-
}
|
|
53
|
-
// launch shell in app dir
|
|
54
|
-
if (shell) {
|
|
55
|
-
(0, child_process_1.startShell)(dir);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
exports.runSeedCommand = runSeedCommand;
|