@journeyapps/cloudcode-build-agent 0.0.0-dev.1377dae → 0.0.0-dev.2b3e822
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/builder.d.ts +1 -15
- package/dist/builder.js +55 -58
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +2 -7
- package/dist/cli.js.map +1 -1
- package/dist/defs.js +25 -14
- package/dist/defs.js.map +1 -1
- package/dist/detect_tasks.d.ts +5 -6
- package/dist/detect_tasks.js +4 -2
- package/dist/detect_tasks.js.map +1 -1
- package/dist/installer.d.ts +0 -5
- package/dist/installer.js +26 -34
- package/dist/installer.js.map +1 -1
- package/dist/run.d.ts +9 -3
- package/dist/run.js +81 -10
- package/dist/run.js.map +1 -1
- package/package.json +2 -1
- package/src/builder.ts +63 -87
- package/src/cli.ts +2 -7
- package/src/defs.ts +26 -15
- package/src/detect_tasks.ts +5 -12
- package/src/installer.ts +29 -33
- package/src/run.ts +104 -15
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/spawn-stream.d.ts +0 -15
- package/dist/spawn-stream.js +0 -59
- package/dist/spawn-stream.js.map +0 -1
- package/src/spawn-stream.ts +0 -73
package/dist/builder.d.ts
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import { DetectedTask } from './detect_tasks';
|
|
2
1
|
export type GeneralTaskConfig = {
|
|
3
2
|
app_id: string;
|
|
4
3
|
env: string;
|
|
5
4
|
backend_id: string;
|
|
6
5
|
backend_url: string;
|
|
7
6
|
};
|
|
8
|
-
export
|
|
9
|
-
only?: string;
|
|
10
|
-
custom_node_installation_path?: string;
|
|
11
|
-
};
|
|
12
|
-
type ToolPaths = {
|
|
13
|
-
bin_path: string;
|
|
14
|
-
node_bin: string;
|
|
15
|
-
npm_bin: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function buildTasks(project_path: string, dest: string, config: GeneralTaskConfig, options?: BuildOptions): Promise<void>;
|
|
18
|
-
export declare function buildTask(task: DetectedTask, project_path: string, dest: string, config: GeneralTaskConfig, node_context: {
|
|
19
|
-
node_version: string;
|
|
20
|
-
} & ToolPaths): Promise<void>;
|
|
21
|
-
export {};
|
|
7
|
+
export declare function buildTasks(project_path: string, dest: string, config: GeneralTaskConfig, only?: string): Promise<void>;
|
package/dist/builder.js
CHANGED
|
@@ -23,79 +23,76 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.buildTasks = void 0;
|
|
27
27
|
const path = __importStar(require("node:path"));
|
|
28
28
|
const jetpack = __importStar(require("fs-jetpack"));
|
|
29
29
|
const semver = __importStar(require("semver"));
|
|
30
|
-
const
|
|
30
|
+
const utils = __importStar(require("./installer"));
|
|
31
31
|
const detect_tasks_1 = require("./detect_tasks");
|
|
32
32
|
const run_1 = require("./run");
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const _ = __importStar(require("lodash"));
|
|
34
|
+
async function buildTasks(project_path, dest, config, only) {
|
|
35
|
+
const tasks = await (0, detect_tasks_1.detectTasks)(project_path, only);
|
|
36
|
+
const required_node_versions = _.compact(tasks.map((t) => t.required_node_version));
|
|
37
|
+
const install_node_versions = _.uniq(required_node_versions);
|
|
38
|
+
// FIXME: Maybe refactor this section into an ensureNodeVersion (or something) that returns the relevant toolpaths?
|
|
39
|
+
const tool_paths = {};
|
|
35
40
|
// Use the version of nodejs that's running this script as the default.
|
|
36
41
|
const default_tool_paths = {
|
|
37
42
|
bin_path: path.dirname(process.execPath),
|
|
38
43
|
node_bin: process.execPath,
|
|
39
44
|
npm_bin: path.join(path.dirname(process.execPath), 'npm')
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
tool_paths[process.version] = default_tool_paths;
|
|
47
|
+
for (const required_node_version of install_node_versions) {
|
|
48
|
+
// FIXME: put this in another directory to avoid leaking into the builder
|
|
49
|
+
const custom_node_path = path.resolve(`node-${semver.major(required_node_version)}`);
|
|
50
|
+
if (!jetpack.exists(path.join(custom_node_path, 'bin/node'))) {
|
|
51
|
+
console.debug(`installing to ${custom_node_path}`);
|
|
52
|
+
await jetpack.dirAsync(custom_node_path);
|
|
53
|
+
await utils.downloadAndInstallNode(required_node_version, custom_node_path);
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
node_version,
|
|
52
|
-
...(custom_tool_paths ?? default_tool_paths)
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.buildTasks = buildTasks;
|
|
57
|
-
async function buildTask(task, project_path, dest, config, node_context) {
|
|
58
|
-
const builder_package = task.builder_package;
|
|
59
|
-
const builder_script = task.builder_script;
|
|
60
|
-
const { bin_path, node_bin, npm_bin } = node_context;
|
|
61
|
-
const builder_bin = path.resolve(bin_path, builder_script);
|
|
62
|
-
if (!jetpack.exists(node_bin)) {
|
|
63
|
-
throw new Error(`Node binary not found: ${node_bin}`);
|
|
64
|
-
}
|
|
65
|
-
console.debug(`[${task.task_name}] Installing builder script "${builder_package}" for node ${node_context.node_version}`);
|
|
66
|
-
const stream1 = (0, run_1.runCommand)(node_bin, [npm_bin, '--global', 'install', builder_package], {
|
|
67
|
-
cwd: project_path,
|
|
68
|
-
env: process.env
|
|
69
|
-
});
|
|
70
|
-
for await (let event of stream1) {
|
|
71
|
-
const log = event.stdout ?? event.stderr;
|
|
72
|
-
if (log) {
|
|
73
|
-
console.log(`[${task.task_name} - install]`, log.trimRight());
|
|
55
|
+
else {
|
|
56
|
+
console.debug(`already installed in ${custom_node_path}`);
|
|
74
57
|
}
|
|
58
|
+
tool_paths[required_node_version] = utils.nodePaths(custom_node_path);
|
|
75
59
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
builder_args.push(`--appId`, config.app_id);
|
|
87
|
-
builder_args.push(`--env`, config.env);
|
|
88
|
-
builder_args.push(`--backendId`, config.backend_id);
|
|
89
|
-
builder_args.push(`--backendUrl`, config.backend_url);
|
|
90
|
-
builder_args.push(`--runInstallScripts`, 'true');
|
|
91
|
-
console.debug(`[${task.task_name}] Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
92
|
-
const stream2 = (0, run_1.runCommand)(node_bin, builder_args, { cwd: project_path, env: process.env });
|
|
93
|
-
for await (let event of stream2) {
|
|
94
|
-
const log = event.stdout ?? event.stderr;
|
|
95
|
-
if (log) {
|
|
96
|
-
console.log(`[${task.task_name} - build]`, log.trimRight());
|
|
60
|
+
console.debug('----');
|
|
61
|
+
for (const task of tasks) {
|
|
62
|
+
const debug = require('debug')(`${task.task_name}`);
|
|
63
|
+
const node_version = task.required_node_version ?? process.version;
|
|
64
|
+
const builder_package = task.builder_package;
|
|
65
|
+
const builder_script = task.builder_script;
|
|
66
|
+
const { bin_path, node_bin, npm_bin } = tool_paths[node_version];
|
|
67
|
+
const builder_bin = path.resolve(bin_path, builder_script);
|
|
68
|
+
if (!jetpack.exists(node_bin)) {
|
|
69
|
+
throw new Error(`Node binary not found: ${node_bin}`);
|
|
97
70
|
}
|
|
71
|
+
// console.debug(`[${task.task_name}] Installing builder script "${builder_package}" for node ${node_version}`);
|
|
72
|
+
debug(`Installing builder script "${builder_package}" for node ${node_version}`);
|
|
73
|
+
// TODO: This may need to be replaced with the something like the spawn-stream stuff in build-agent? OR what to do with the stdout/stderr and errorhandling?
|
|
74
|
+
await (0, run_1.runCommand)(node_bin, [npm_bin, '--global', 'install', builder_package], { cwd: project_path }, { task_name: task.task_name });
|
|
75
|
+
if (!jetpack.exists(builder_bin)) {
|
|
76
|
+
console.error(`[${task.task_name}] ${builder_bin} not found`);
|
|
77
|
+
throw new Error(`Builder script not found for task ${task.task_name}`);
|
|
78
|
+
}
|
|
79
|
+
const builder_args = [];
|
|
80
|
+
// --src ./ --out ./dist/echo --task echo --appId 'appid' --env 'testing' --backendId 'backendid' --backendUrl 'http://run.journeyapps.test'
|
|
81
|
+
builder_args.push(builder_bin);
|
|
82
|
+
builder_args.push('--src', project_path);
|
|
83
|
+
builder_args.push(`--out`, path.join(dest, task.task_name));
|
|
84
|
+
builder_args.push(`--zip`, path.join(dest, `${task.task_name}.zip`));
|
|
85
|
+
builder_args.push(`--task`, `${task.task_name}`);
|
|
86
|
+
builder_args.push(`--appId`, config.app_id);
|
|
87
|
+
builder_args.push(`--env`, config.env);
|
|
88
|
+
builder_args.push(`--backendId`, config.backend_id);
|
|
89
|
+
builder_args.push(`--backendUrl`, config.backend_url);
|
|
90
|
+
// builder_args.push(`--runInstallScripts`, 'true'); // TODO: handle this from feature flags somehow
|
|
91
|
+
// console.debug(`[${task.task_name}] Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
92
|
+
debug(`Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
93
|
+
await (0, run_1.runCommand)(node_bin, builder_args, { cwd: project_path }, { task_name: task.task_name });
|
|
94
|
+
console.debug('----');
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
exports.
|
|
97
|
+
exports.buildTasks = buildTasks;
|
|
101
98
|
//# sourceMappingURL=builder.js.map
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AACjC,mDAAqC;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,KAAK,CAAC,MAAM,CAAC,CAAC;KACvB;AACH,CAAC;AA7ED,gCA6EC"}
|
package/dist/cli.js
CHANGED
|
@@ -27,8 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const yargs = __importStar(require("yargs"));
|
|
28
28
|
const _1 = require("./");
|
|
29
29
|
const DEFAULT_SRC_PATH = './';
|
|
30
|
-
const DEFAULT_OUT_PATH = './dist
|
|
31
|
-
const DEFAULT_TMP_PATH = '/tmp/cloudcode-build-agent/node';
|
|
30
|
+
const DEFAULT_OUT_PATH = './dist';
|
|
32
31
|
yargs
|
|
33
32
|
.command(['build', '$0'], // $0 means this is the default command
|
|
34
33
|
'build tasks', (yargs) => {
|
|
@@ -36,7 +35,6 @@ yargs
|
|
|
36
35
|
.option('only', { string: true })
|
|
37
36
|
.option('path', { default: DEFAULT_SRC_PATH })
|
|
38
37
|
.option('out', { default: DEFAULT_OUT_PATH })
|
|
39
|
-
.option('node_work_dir', { default: DEFAULT_TMP_PATH })
|
|
40
38
|
// TODO: investigate yargs.config() for reading task config blob from a file. But how to ensure required args?
|
|
41
39
|
.option('appId', { string: true, demandOption: true, describe: "CloudCode's reference id" })
|
|
42
40
|
.option('env', { string: true, demandOption: true })
|
|
@@ -49,10 +47,7 @@ yargs
|
|
|
49
47
|
backend_id: argv.backendId,
|
|
50
48
|
backend_url: argv.backendUrl
|
|
51
49
|
};
|
|
52
|
-
await (0, _1.buildTasks)(argv.path, argv.out, config,
|
|
53
|
-
only: argv.only,
|
|
54
|
-
custom_node_installation_path: argv.node_work_dir
|
|
55
|
-
});
|
|
50
|
+
await (0, _1.buildTasks)(argv.path, argv.out, config, argv.only);
|
|
56
51
|
}))
|
|
57
52
|
.option('verbose', {
|
|
58
53
|
alias: 'v',
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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AAG;QACb,UAAU,EAAE,IAAI,CAAC,SAAS;QAC1B,WAAW,EAAE,IAAI,CAAC,UAAU;KAC7B,CAAC;IACF,MAAM,IAAA,aAAU,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC,CAAC,CACH;KACA,MAAM,CAAC,SAAS,EAAE;IACjB,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,KAAK;CACf,CAAC,CAAC,IAAI,CAAC;AAEV,SAAS,OAAO,CAAI,EAA8B;IAChD,OAAO,KAAK,EAAE,IAAO,EAAE,EAAE;QACvB,IAAI;YACF,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;SAChB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/defs.js
CHANGED
|
@@ -3,35 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SUPPORTED_VERSIONS = void 0;
|
|
4
4
|
// TODO: maybe publish (some of) this from the CC service?
|
|
5
5
|
exports.SUPPORTED_VERSIONS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
{
|
|
7
|
+
// proposed
|
|
8
|
+
version: '1.13.0',
|
|
9
|
+
node: '16.19.1',
|
|
10
|
+
builder_package: '@journeyapps/cloudcode-build@1.13.0',
|
|
11
|
+
builder_script: 'cloudcode-build'
|
|
12
|
+
},
|
|
13
13
|
{
|
|
14
14
|
version: '1.12.0',
|
|
15
15
|
node: '16.19.1',
|
|
16
|
-
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
16
|
+
// builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
17
|
+
// DEV HACK:
|
|
18
|
+
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
17
19
|
builder_script: 'cloudcode-build-legacy'
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
version: '1.11.2',
|
|
21
|
-
node: '14.21.3',
|
|
22
|
-
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
23
|
+
// node: '14.21.3',
|
|
24
|
+
// builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
25
|
+
// DEV HACK:
|
|
26
|
+
node: '16.19.1',
|
|
27
|
+
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
23
28
|
builder_script: 'cloudcode-build-legacy'
|
|
24
29
|
},
|
|
25
30
|
{
|
|
26
31
|
version: '1.11.1',
|
|
27
|
-
node: '14.21.3',
|
|
28
|
-
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
32
|
+
// node: '14.21.3',
|
|
33
|
+
// builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
34
|
+
// DEV HACK:
|
|
35
|
+
node: '16.19.1',
|
|
36
|
+
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
29
37
|
builder_script: 'cloudcode-build-legacy'
|
|
30
38
|
},
|
|
31
39
|
{
|
|
32
40
|
version: '1.11.0',
|
|
33
|
-
node: '14.21.3',
|
|
34
|
-
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
41
|
+
// node: '14.21.3',
|
|
42
|
+
// builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0'
|
|
43
|
+
// DEV HACK:
|
|
44
|
+
node: '16.19.1',
|
|
45
|
+
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
35
46
|
builder_script: 'cloudcode-build-legacy'
|
|
36
47
|
}
|
|
37
48
|
];
|
package/dist/defs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.js","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC7C,QAAA,kBAAkB,GAAG;IAChC
|
|
1
|
+
{"version":3,"file":"defs.js","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC7C,QAAA,kBAAkB,GAAG;IAChC;QACE,WAAW;QACX,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,qCAAqC;QACtD,cAAc,EAAE,iBAAiB;KAClC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,gEAAgE;QAChE,YAAY;QACZ,eAAe,EAAE,yDAAyD;QAC1E,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,mBAAmB;QACnB,gEAAgE;QAChE,YAAY;QACZ,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,yDAAyD;QAC1E,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,mBAAmB;QACnB,gEAAgE;QAChE,YAAY;QACZ,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,yDAAyD;QAC1E,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,mBAAmB;QACnB,gEAAgE;QAChE,YAAY;QACZ,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,yDAAyD;QAC1E,cAAc,EAAE,wBAAwB;KACzC;CACF,CAAC"}
|
package/dist/detect_tasks.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function detectTasks(project_path: string, only?: string): Promise<{
|
|
2
2
|
pkg_path: string;
|
|
3
|
-
task_name:
|
|
4
|
-
task_version:
|
|
5
|
-
required_node_version
|
|
3
|
+
task_name: any;
|
|
4
|
+
task_version: any;
|
|
5
|
+
required_node_version: string | undefined;
|
|
6
6
|
builder_package: string;
|
|
7
7
|
builder_script: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function detectTasks(project_path: string, only?: string): Promise<DetectedTask[]>;
|
|
8
|
+
}[]>;
|
package/dist/detect_tasks.js
CHANGED
|
@@ -29,6 +29,7 @@ const path = __importStar(require("node:path"));
|
|
|
29
29
|
const jetpack = __importStar(require("fs-jetpack"));
|
|
30
30
|
const semver = __importStar(require("semver"));
|
|
31
31
|
const defs = __importStar(require("./defs"));
|
|
32
|
+
// TODO: validations for cloudcode specific keys and structure?
|
|
32
33
|
async function readPackage(path) {
|
|
33
34
|
try {
|
|
34
35
|
const content = await fs.promises.readFile(path, { encoding: 'utf-8' });
|
|
@@ -71,8 +72,9 @@ async function detectTasks(project_path, only) {
|
|
|
71
72
|
console.debug(`Matching versions: ${JSON.stringify(matching)}`);
|
|
72
73
|
const running_node_version = process.versions.node;
|
|
73
74
|
let required_node_version;
|
|
74
|
-
if (matching?.node && semver.major(matching.node) !== semver.major(running_node_version)) {
|
|
75
|
-
|
|
75
|
+
// if (matching?.node && semver.major(matching.node) !== semver.major(running_node_version)) {
|
|
76
|
+
if (matching?.node && semver.parse(matching.node) !== semver.parse(running_node_version)) {
|
|
77
|
+
console.debug(`Task requires different node version: v${matching.node}`);
|
|
76
78
|
required_node_version = matching.node;
|
|
77
79
|
}
|
|
78
80
|
return {
|
package/dist/detect_tasks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect_tasks.js","sourceRoot":"","sources":["../src/detect_tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AACjC,6CAA+B;AAE/B,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EA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AQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAEzE,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC;SACvC;QACD,OAAO;YACL,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,qBAAqB;YACrB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAtDD,kCAsDC"}
|
package/dist/installer.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export declare function ensureCustomNodeVersion(node_version: string, install_path: string): Promise<{
|
|
2
|
-
bin_path: string;
|
|
3
|
-
node_bin: string;
|
|
4
|
-
npm_bin: string;
|
|
5
|
-
}>;
|
|
6
1
|
export declare function downloadAndInstallNode(node_version: string, destination: string): Promise<{
|
|
7
2
|
bin_path: string;
|
|
8
3
|
node_bin: string;
|
package/dist/installer.js
CHANGED
|
@@ -26,26 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.downloadAndExtractTarball = exports.nodePaths = exports.downloadAndInstallNode =
|
|
30
|
-
const jetpack = __importStar(require("fs-jetpack"));
|
|
31
|
-
const path = __importStar(require("node:path"));
|
|
32
|
-
const URL = __importStar(require("node:url"));
|
|
29
|
+
exports.downloadAndExtractTarball = exports.nodePaths = exports.downloadAndInstallNode = void 0;
|
|
33
30
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
34
32
|
const fs = __importStar(require("node:fs"));
|
|
35
33
|
const os = __importStar(require("node:os"));
|
|
34
|
+
const URL = __importStar(require("node:url"));
|
|
36
35
|
const tar = __importStar(require("tar"));
|
|
37
|
-
async function ensureCustomNodeVersion(node_version, install_path) {
|
|
38
|
-
if (!jetpack.exists(path.join(install_path, 'bin/node'))) {
|
|
39
|
-
console.debug(`[node ${node_version}] Installing to ${install_path}`);
|
|
40
|
-
await jetpack.dirAsync(install_path);
|
|
41
|
-
await downloadAndInstallNode(node_version, install_path);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.debug(`[node ${node_version}] Already installed in ${install_path}`);
|
|
45
|
-
}
|
|
46
|
-
return nodePaths(install_path);
|
|
47
|
-
}
|
|
48
|
-
exports.ensureCustomNodeVersion = ensureCustomNodeVersion;
|
|
49
36
|
/* Basically this, but for different dirs.
|
|
50
37
|
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${PLATFORM}64.tar.gz -L | tar -xzC /node-dedicated && \
|
|
51
38
|
mv /node-dedicated/node-v${NODE_VERSION}-linux-${PLATFORM}64/bin/node /node-dedicated/node
|
|
@@ -53,10 +40,14 @@ exports.ensureCustomNodeVersion = ensureCustomNodeVersion;
|
|
|
53
40
|
// TODO: feature to find the latest minor and patch for a given major version?
|
|
54
41
|
async function downloadAndInstallNode(node_version, destination) {
|
|
55
42
|
// eg. https://nodejs.org/dist/v18.14.2/node-v18.14.2-linux-x64.tar.xz
|
|
43
|
+
// const PLATFORM = 'x';
|
|
44
|
+
// const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-${PLATFORM}64.tar.gz`;
|
|
45
|
+
// TODO: this is just for dev for now. Find a better fix.
|
|
56
46
|
const ARCH = os.arch();
|
|
57
47
|
const PLATFORM = os.platform();
|
|
58
48
|
const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-${PLATFORM}-${ARCH}.tar.gz`;
|
|
59
49
|
await downloadAndExtractTarball(node_download_url, destination);
|
|
50
|
+
// TODO: move binaries into local bin path?
|
|
60
51
|
return nodePaths(destination);
|
|
61
52
|
}
|
|
62
53
|
exports.downloadAndInstallNode = downloadAndInstallNode;
|
|
@@ -84,11 +75,13 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
84
75
|
const errorBody = await response.statusText;
|
|
85
76
|
throw new Error(`Failed to download: ${errorBody}`);
|
|
86
77
|
}
|
|
78
|
+
// FIXME: replace with webstreams? but according to the types package webstreams aren't available in node 16?!??
|
|
87
79
|
const file = fs.createWriteStream(download); // Sink the download stream into a file, so it can be extracted.
|
|
88
80
|
response.body.pipe(file);
|
|
89
81
|
file.on('finish', async () => {
|
|
90
82
|
try {
|
|
91
|
-
console.
|
|
83
|
+
console.log('Extracting...', download);
|
|
84
|
+
// const comp = fs.createReadStream(download);
|
|
92
85
|
tar.extract({
|
|
93
86
|
cwd: tmpdir,
|
|
94
87
|
file: download,
|
|
@@ -101,29 +94,28 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
101
94
|
// fs.rmSync(dist, { recursive: true });
|
|
102
95
|
// }
|
|
103
96
|
if (fs.existsSync(uncomp)) {
|
|
104
|
-
console.
|
|
97
|
+
console.log(`Moving extracted files from ${uncomp} to ${dist}`);
|
|
105
98
|
fs.renameSync(uncomp, dist);
|
|
106
99
|
}
|
|
107
100
|
else {
|
|
108
|
-
console.
|
|
101
|
+
console.log(`Can't find extract dir ${uncomp}`);
|
|
109
102
|
}
|
|
103
|
+
// FIXME: this seems to sometimes cause errors
|
|
110
104
|
/*
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
^
|
|
105
|
+
----
|
|
106
|
+
node:events:505
|
|
107
|
+
throw er; // Unhandled 'error' event
|
|
108
|
+
^
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```
|
|
110
|
+
Error: ENOENT: no such file or directory, open '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
111
|
+
Emitted 'error' event on ReadStream instance at:
|
|
112
|
+
at emitErrorNT (node:internal/streams/destroy:157:8)
|
|
113
|
+
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
|
|
114
|
+
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
|
|
115
|
+
errno: -2,
|
|
116
|
+
code: 'ENOENT',
|
|
117
|
+
syscall: 'open',
|
|
118
|
+
path: '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
127
119
|
*/
|
|
128
120
|
// fs.unlinkSync(file.path);
|
|
129
121
|
resolve(null);
|
package/dist/installer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,gDAAkC;AAClC,4CAA8B;AAC9B,4CAA8B;AAC9B,8CAAgC;AAChC,yCAA2B;AAE3B;;;EAGE;AACF,8EAA8E;AACvE,KAAK,UAAU,sBAAsB,CAAC,YAAoB,EAAE,WAAmB;IACpF,sEAAsE;IAEtE,wBAAwB;IACxB,yHAAyH;IAEzH,yDAAyD;IACzD,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,iBAAiB,GAAG,4BAA4B,YAAY,UAAU,YAAY,IAAI,QAAQ,IAAI,IAAI,SAAS,CAAC;IAEtH,MAAM,yBAAyB,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAChE,2CAA2C;IAC3C,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC;AAdD,wDAcC;AAED,SAAgB,SAAS,CAAC,WAAmB;IAC3C,OAAO;QACL,QAAQ,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import { SpawnOptions } from 'child_process';
|
|
4
|
-
export declare function runCommand(command: string,
|
|
2
|
+
import { Options } from 'child-process-promise';
|
|
3
|
+
import type { SpawnOptions } from 'child_process';
|
|
4
|
+
export declare function runCommand(command: string, commandArgs: string[], options: RunCommandOpts | undefined, context: {
|
|
5
|
+
task_name: string;
|
|
6
|
+
}): Promise<import("child-process-promise").SpawnPromiseResult>;
|
|
7
|
+
type RunCommandOpts = {
|
|
8
|
+
logPrefix?: string;
|
|
9
|
+
} & Readonly<Options & SpawnOptions>;
|
|
10
|
+
export {};
|
package/dist/run.js
CHANGED
|
@@ -1,19 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCommand = void 0;
|
|
4
|
-
const
|
|
5
|
-
async function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const child_process_promise_1 = require("child-process-promise");
|
|
5
|
+
async function runCommand(command, commandArgs, options = {}, context) {
|
|
6
|
+
const debug = require('debug')(`${context.task_name} build`);
|
|
7
|
+
const errors = [];
|
|
8
|
+
const defaultLogLine = (isStderr, line, childProcess) => {
|
|
9
|
+
if (isStderr) {
|
|
10
|
+
if (line.startsWith('warning package.json: No license field')) {
|
|
11
|
+
// This is a noisy yarn warning, ignore it.
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
errors.push(line);
|
|
12
15
|
}
|
|
16
|
+
};
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
result = await spawnPromise(command, commandArgs, { logLine: defaultLogLine, ...options }, context);
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (errors.length > 0) {
|
|
23
|
+
// Handled below
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Exit code without any logged errors.
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (result) {
|
|
31
|
+
debug('exit code:', result.code);
|
|
32
|
+
}
|
|
33
|
+
if (errors.length > 0) {
|
|
34
|
+
// We consider this a failure, regardless of exit code.
|
|
35
|
+
// In general, we expect errors to be accompanied by an error code of 1 (and vice versa),
|
|
36
|
+
// but we do not depend on that behaviour.
|
|
37
|
+
throw new Error('Error: ' + errors.join('\n'));
|
|
38
|
+
}
|
|
39
|
+
if (result?.code === 0) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error(`Error code '${result?.code}' while running command`);
|
|
16
44
|
}
|
|
17
45
|
}
|
|
18
46
|
exports.runCommand = runCommand;
|
|
47
|
+
/**
|
|
48
|
+
* Run a command and log the output. Ported from stack-versioned
|
|
49
|
+
*/
|
|
50
|
+
async function spawnPromise(command, commandArgs, options = {}, context) {
|
|
51
|
+
const debug = require('debug')(`${context.task_name} build`);
|
|
52
|
+
let logPrefix = options.logPrefix || '';
|
|
53
|
+
delete options.logPrefix;
|
|
54
|
+
if (logPrefix) {
|
|
55
|
+
logPrefix += ' ';
|
|
56
|
+
}
|
|
57
|
+
const logLine = options.logLine;
|
|
58
|
+
delete options.receivedLines;
|
|
59
|
+
let logBuffer = '';
|
|
60
|
+
const log = (isStderr, data) => {
|
|
61
|
+
data = data.toString();
|
|
62
|
+
let trimmed = data.replace(/[\n|\r|\r\n]$/, '');
|
|
63
|
+
if (trimmed.length == data.length) {
|
|
64
|
+
logBuffer += trimmed;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (logBuffer.length > 0) {
|
|
68
|
+
trimmed = logBuffer + trimmed;
|
|
69
|
+
logBuffer = '';
|
|
70
|
+
}
|
|
71
|
+
trimmed.split('\n').forEach((line) => {
|
|
72
|
+
debug(`${logPrefix}${line}`);
|
|
73
|
+
if (logLine) {
|
|
74
|
+
logLine(isStderr, line, spawnPromise.childProcess);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
debug(`${logPrefix}(${options.cwd || '.'}) \$ ${commandArgs.join(' ')}`);
|
|
79
|
+
let spawnPromise = (0, child_process_promise_1.spawn)(command, commandArgs, options);
|
|
80
|
+
spawnPromise.childProcess.stdout.on('data', log.bind(null, false));
|
|
81
|
+
spawnPromise.childProcess.stderr.on('data', log.bind(null, true));
|
|
82
|
+
try {
|
|
83
|
+
return await spawnPromise;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
spawnPromise.childProcess.stdout.removeAllListeners('data');
|
|
87
|
+
spawnPromise.childProcess.stderr.removeAllListeners('data');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
19
90
|
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;AAAA,iEAAuD;AAGhD,KAAK,UAAU,UAAU,CAC9B,OAAe,EACf,WAAqB,EACrB,UAA0B,EAAE,EAC5B,OAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,QAAQ,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,cAAc,GAAG,CAAC,QAAiB,EAAE,IAAY,EAAE,YAAiB,EAAE,EAAE;QAC5E,IAAI,QAAQ,EAAE;YACZ,IAAI,IAAI,CAAC,UAAU,CAAC,wCAAwC,CAAC,EAAE;gBAC7D,2CAA2C;gBAC3C,OAAO;aACR;YACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;IACH,CAAC,CAAC;IACF,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,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AC7D,YAAY,CAAC,YAAY,CAAC,MAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;KAC9D;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/cloudcode-build-agent",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.2b3e822",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"types": "./dist/index",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"child-process-promise": "^2.2.1",
|
|
13
|
+
"debug": "^2.6.0",
|
|
13
14
|
"fs-jetpack": "5.1.0",
|
|
14
15
|
"lodash": "4.17.21",
|
|
15
16
|
"node-fetch": "<3",
|