@journeyapps/cloudcode-build-agent 0.0.0-dev.6fdb5b1 → 0.0.0-dev.8215bb7
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 +16 -1
- package/dist/builder.js +69 -68
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +9 -10
- package/dist/cli.js.map +1 -1
- package/dist/defs.d.ts +1 -0
- package/dist/defs.js +19 -25
- package/dist/defs.js.map +1 -1
- package/dist/detect_tasks.d.ts +7 -5
- package/dist/detect_tasks.js +4 -4
- package/dist/detect_tasks.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/{utils.d.ts → installer.d.ts} +8 -0
- package/dist/{utils.js → installer.js} +38 -29
- package/dist/installer.js.map +1 -0
- package/dist/run.d.ts +4 -0
- package/dist/run.js +19 -0
- package/dist/run.js.map +1 -0
- package/dist/spawn-stream.d.ts +15 -0
- package/dist/spawn-stream.js +59 -0
- package/dist/spawn-stream.js.map +1 -0
- package/package.json +12 -4
- package/dist/errors.d.ts +0 -8
- package/dist/errors.js +0 -21
- package/dist/errors.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/src/builder.ts +0 -101
- package/src/cli.ts +0 -56
- package/src/defs.ts +0 -45
- package/src/detect_tasks.ts +0 -74
- package/src/errors.ts +0 -22
- package/src/index.ts +0 -2
- package/src/utils.ts +0 -113
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/builder.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import { DetectedTask } from './detect_tasks';
|
|
1
2
|
export type GeneralTaskConfig = {
|
|
2
3
|
app_id: string;
|
|
3
4
|
env: string;
|
|
4
5
|
backend_id: string;
|
|
5
6
|
backend_url: string;
|
|
6
7
|
};
|
|
7
|
-
export
|
|
8
|
+
export type BuildOptions = {
|
|
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
|
+
npx_bin: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function buildTasks(project_path: string, dest: string, config: GeneralTaskConfig, options?: BuildOptions): Promise<void>;
|
|
19
|
+
export declare function buildTask(task: DetectedTask, project_path: string, dest: string, config: GeneralTaskConfig, node_context: {
|
|
20
|
+
node_version: string;
|
|
21
|
+
} & ToolPaths): Promise<void>;
|
|
22
|
+
export {};
|
package/dist/builder.js
CHANGED
|
@@ -23,88 +23,89 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.buildTasks = void 0;
|
|
26
|
+
exports.buildTask = 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
|
|
31
|
-
const child_process_1 = require("child_process");
|
|
30
|
+
const installer_1 = require("./installer");
|
|
32
31
|
const detect_tasks_1 = require("./detect_tasks");
|
|
33
|
-
const
|
|
34
|
-
async function buildTasks(project_path, dest, config,
|
|
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 = {};
|
|
32
|
+
const run_1 = require("./run");
|
|
33
|
+
async function buildTasks(project_path, dest, config, options) {
|
|
34
|
+
const tasks = await (0, detect_tasks_1.detectTasks)(project_path, options?.only);
|
|
40
35
|
// Use the version of nodejs that's running this script as the default.
|
|
41
36
|
const default_tool_paths = {
|
|
42
37
|
bin_path: path.dirname(process.execPath),
|
|
43
38
|
node_bin: process.execPath,
|
|
44
|
-
npm_bin: path.join(path.dirname(process.execPath), 'npm')
|
|
39
|
+
npm_bin: path.join(path.dirname(process.execPath), 'npm'),
|
|
40
|
+
npx_bin: path.join(path.dirname(process.execPath), 'npx')
|
|
45
41
|
};
|
|
46
|
-
tool_paths[process.version] = default_tool_paths;
|
|
47
|
-
for (const required_node_version of install_node_versions) {
|
|
48
|
-
const custom_node_path = path.resolve(`node-${semver.major(required_node_version)}`);
|
|
49
|
-
if (!jetpack.exists(path.join(custom_node_path, 'bin/node'))) {
|
|
50
|
-
console.debug(`installing to ${custom_node_path}`);
|
|
51
|
-
await jetpack.dirAsync(custom_node_path);
|
|
52
|
-
await utils.downloadAndInstallNode(required_node_version, custom_node_path);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
console.debug(`already installed in ${custom_node_path}`);
|
|
56
|
-
}
|
|
57
|
-
tool_paths[required_node_version] = utils.nodePaths(custom_node_path);
|
|
58
|
-
}
|
|
59
|
-
console.debug('----');
|
|
60
42
|
for (const task of tasks) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
throw new Error(`Node binary not found: ${node_bin}`);
|
|
43
|
+
let custom_tool_paths;
|
|
44
|
+
if (task.required_node_version) {
|
|
45
|
+
// FIXME: when defaulting to project_path, the custom node installation is copied into the builder's workdir as well.
|
|
46
|
+
const custom_node_installation_path = options?.custom_node_installation_path ?? project_path;
|
|
47
|
+
const custom_node_path = path.resolve(custom_node_installation_path, `node-${semver.major(task.required_node_version)}`);
|
|
48
|
+
custom_tool_paths = await (0, installer_1.ensureCustomNodeVersion)(task.required_node_version, custom_node_path);
|
|
68
49
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
50
|
+
const node_version = task.required_node_version ?? process.version;
|
|
51
|
+
await buildTask(task, project_path, dest, config, {
|
|
52
|
+
node_version,
|
|
53
|
+
...(custom_tool_paths ?? default_tool_paths)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.buildTasks = buildTasks;
|
|
58
|
+
async function buildTask(task, project_path, dest, config, node_context) {
|
|
59
|
+
const builder_package = task.builder_package;
|
|
60
|
+
const builder_script = task.builder_script;
|
|
61
|
+
const { node_bin, npm_bin, npx_bin } = node_context;
|
|
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
|
+
/*
|
|
67
|
+
* The builder package is installed locally so as to not require write access to the global node installation,
|
|
68
|
+
* and executed with npx to handle the path resoluton, etc.
|
|
69
|
+
*/
|
|
70
|
+
const stream1 = (0, run_1.runCommand)(node_bin, [npm_bin, '--no-save', '--no-fund', '--no-audit', 'install', builder_package], {
|
|
71
|
+
cwd: project_path,
|
|
72
|
+
env: {
|
|
73
|
+
npm_config_loglevel: 'error',
|
|
74
|
+
...process.env
|
|
81
75
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
builder_args.push(`--task`, `${task.task_name}`);
|
|
88
|
-
builder_args.push(`--appId`, config.app_id);
|
|
89
|
-
builder_args.push(`--env`, config.env);
|
|
90
|
-
builder_args.push(`--backendId`, config.backend_id);
|
|
91
|
-
builder_args.push(`--backendUrl`, config.backend_url);
|
|
92
|
-
// builder_args.push(`--runInstallScripts`, 'true'); // TODO: handle this from feature flags somehow
|
|
93
|
-
console.debug(`[${task.task_name}] Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
94
|
-
const builderSpawnResult = (0, child_process_1.spawnSync)(node_bin, builder_args, { cwd: project_path });
|
|
95
|
-
if (builderSpawnResult.status !== 0) {
|
|
96
|
-
console.error(`[${task.task_name}] FAILED TO RUN BUILDER SCRIPT`);
|
|
97
|
-
console.debug(`[${task.task_name}] STDOUT: ${builderSpawnResult.stdout}`);
|
|
98
|
-
console.debug(`[${task.task_name}] STDERR: ${builderSpawnResult.stderr}`);
|
|
76
|
+
});
|
|
77
|
+
for await (let event of stream1) {
|
|
78
|
+
const log = event.stdout ?? event.stderr;
|
|
79
|
+
if (log) {
|
|
80
|
+
console.log(`[${task.task_name} - install]`, log.trimRight());
|
|
99
81
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
82
|
+
}
|
|
83
|
+
const build_metadata = {
|
|
84
|
+
name: task.task_name,
|
|
85
|
+
version: task.task_version,
|
|
86
|
+
lambda_runtime: task.task_runtime
|
|
87
|
+
};
|
|
88
|
+
await jetpack.writeAsync(path.join(dest, `${task.task_name}-metadata.json`), JSON.stringify(build_metadata));
|
|
89
|
+
const builder_args = [];
|
|
90
|
+
builder_args.push(builder_script);
|
|
91
|
+
builder_args.push('--src', project_path);
|
|
92
|
+
builder_args.push(`--out`, path.join(dest, task.task_name));
|
|
93
|
+
builder_args.push(`--zip`, path.join(dest, `${task.task_name}.zip`));
|
|
94
|
+
builder_args.push(`--task`, `${task.task_name}`);
|
|
95
|
+
builder_args.push(`--appId`, config.app_id);
|
|
96
|
+
builder_args.push(`--env`, config.env);
|
|
97
|
+
builder_args.push(`--backendId`, config.backend_id);
|
|
98
|
+
builder_args.push(`--backendUrl`, config.backend_url);
|
|
99
|
+
builder_args.push(`--runInstallScripts`, 'true');
|
|
100
|
+
console.debug(`[${task.task_name}] Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
101
|
+
const stream2 = (0, run_1.runCommand)(npx_bin, ['--no-install', ...builder_args], { cwd: project_path, env: process.env });
|
|
102
|
+
for await (let event of stream2) {
|
|
103
|
+
const log = event.stdout ?? event.stderr;
|
|
104
|
+
if (log) {
|
|
105
|
+
console.log(`[${task.task_name} - build]`, log.trimRight());
|
|
105
106
|
}
|
|
106
|
-
console.debug('----');
|
|
107
107
|
}
|
|
108
|
+
console.log(`[${task.task_name} - build]`, `Finished.`);
|
|
108
109
|
}
|
|
109
|
-
exports.
|
|
110
|
+
exports.buildTask = buildTask;
|
|
110
111
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AAEjC,2CAAsD;AACtD,iDAA2D;AAC3D,+BAAmC;AAkB5B,KAAK,UAAU,UAAU,CAC9B,YAAoB,EACpB,IAAY,EACZ,MAAyB,EACzB,OAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,IAAA,0BAAW,EAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAE7D,uEAAuE;IACvE,MAAM,kBAAkB,GAAG;QACzB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;QACzD,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;KAC1D,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI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,EAAE,CAAC,CAAC;IACjD,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACpD,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACtD,YAAY,CAAC,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAEjD,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,aAAa,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEnF,MAAM,OAAO,GAAG,IAAA,gBAAU,EAAC,OAAO,EAAE,CAAC,cAAc,EAAE,GAAG,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEhH,IAAI,KAAK,EAAE,IAAI,KAAK,IAAI,OAAO,EAAE;QAC/B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACzC,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,WAAW,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;SAC7D;KACF;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,WAAW,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC;AApED,8BAoEC"}
|
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,8 @@ 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';
|
|
30
|
+
const DEFAULT_OUT_PATH = './dist/cloudcode';
|
|
31
|
+
const DEFAULT_TMP_PATH = '/tmp/cloudcode-build-agent/node';
|
|
31
32
|
yargs
|
|
32
33
|
.command(['build', '$0'], // $0 means this is the default command
|
|
33
34
|
'build tasks', (yargs) => {
|
|
@@ -35,6 +36,7 @@ yargs
|
|
|
35
36
|
.option('only', { string: true })
|
|
36
37
|
.option('path', { default: DEFAULT_SRC_PATH })
|
|
37
38
|
.option('out', { default: DEFAULT_OUT_PATH })
|
|
39
|
+
.option('node_work_dir', { default: DEFAULT_TMP_PATH })
|
|
38
40
|
// TODO: investigate yargs.config() for reading task config blob from a file. But how to ensure required args?
|
|
39
41
|
.option('appId', { string: true, demandOption: true, describe: "CloudCode's reference id" })
|
|
40
42
|
.option('env', { string: true, demandOption: true })
|
|
@@ -47,7 +49,10 @@ yargs
|
|
|
47
49
|
backend_id: argv.backendId,
|
|
48
50
|
backend_url: argv.backendUrl
|
|
49
51
|
};
|
|
50
|
-
await (0, _1.buildTasks)(argv.path, argv.out, config,
|
|
52
|
+
await (0, _1.buildTasks)(argv.path, argv.out, config, {
|
|
53
|
+
only: argv.only,
|
|
54
|
+
custom_node_installation_path: argv.node_work_dir
|
|
55
|
+
});
|
|
51
56
|
}))
|
|
52
57
|
.option('verbose', {
|
|
53
58
|
alias: 'v',
|
|
@@ -59,14 +64,8 @@ function handled(fn) {
|
|
|
59
64
|
await fn(argv);
|
|
60
65
|
}
|
|
61
66
|
catch (err) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
process.exit(err.status);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.error(err.stack);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
67
|
+
console.error(err.stack);
|
|
68
|
+
process.exit(1);
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA+B;AAE/B,yBAAgC;AAEhC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAE3D,KAAK;KACF,OAAO,CACN,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,uCAAuC;AACxD,aAAa,EACb,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,KAAK;SACF,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;SAC7C,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;SAC5C,MAAM,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;QACvD,8GAA8G;SAC7G,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,0BAA0B,EAAE,CAAC;SAC3F,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACzD,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAC9D,CAAC;AACJ,CAAC,EACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,MAAM,GAAG;QACb,MAAM,EAAE,IAAI,CAAC,KAAK;QAClB,GAAG,EAAE,IAAI,CAAC,GAAG;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;QAC5C,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,6BAA6B,EAAE,IAAI,CAAC,aAAa;KAClD,CAAC,CAAC;AACL,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.d.ts
CHANGED
package/dist/defs.js
CHANGED
|
@@ -3,46 +3,40 @@ 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: '18.14.2',
|
|
10
|
+
// runtime: 'nodejs18.x',
|
|
11
|
+
// builder_package: '@journeyapps/cloudcode-build@1.13.0',
|
|
12
|
+
// builder_script: 'cloudcode-build'
|
|
13
|
+
// },
|
|
13
14
|
{
|
|
14
15
|
version: '1.12.0',
|
|
15
16
|
node: '16.19.1',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
17
|
+
runtime: 'nodejs16.x',
|
|
18
|
+
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
19
19
|
builder_script: 'cloudcode-build-legacy'
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
version: '1.11.2',
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
node: '16.19.1',
|
|
27
|
-
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
23
|
+
node: '14.21.3',
|
|
24
|
+
runtime: 'nodejs14.x',
|
|
25
|
+
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
28
26
|
builder_script: 'cloudcode-build-legacy'
|
|
29
27
|
},
|
|
30
28
|
{
|
|
31
29
|
version: '1.11.1',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
node: '16.19.1',
|
|
36
|
-
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
30
|
+
node: '14.21.3',
|
|
31
|
+
runtime: 'nodejs14.x',
|
|
32
|
+
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
37
33
|
builder_script: 'cloudcode-build-legacy'
|
|
38
34
|
},
|
|
39
35
|
{
|
|
40
36
|
version: '1.11.0',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
node: '16.19.1',
|
|
45
|
-
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
37
|
+
node: '14.21.3',
|
|
38
|
+
runtime: 'nodejs14.x',
|
|
39
|
+
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
46
40
|
builder_script: 'cloudcode-build-legacy'
|
|
47
41
|
}
|
|
48
42
|
];
|
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,IAAI;IACJ,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;IACrB,2BAA2B;IAC3B,4DAA4D;IAC5D,sCAAsC;IACtC,KAAK;IACL;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,qCAAqC;QACtD,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,qCAAqC;QACtD,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,qCAAqC;QACtD,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,qCAAqC;QACtD,cAAc,EAAE,wBAAwB;KACzC;CACF,CAAC"}
|
package/dist/detect_tasks.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type DetectedTask = {
|
|
2
2
|
pkg_path: string;
|
|
3
|
-
task_name:
|
|
4
|
-
task_version:
|
|
5
|
-
|
|
3
|
+
task_name: string;
|
|
4
|
+
task_version: string;
|
|
5
|
+
task_runtime: string;
|
|
6
|
+
required_node_version?: string;
|
|
6
7
|
builder_package: string;
|
|
7
8
|
builder_script: string;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
10
|
+
export declare function detectTasks(project_path: string, only?: string): Promise<DetectedTask[]>;
|
package/dist/detect_tasks.js
CHANGED
|
@@ -29,7 +29,6 @@ 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?
|
|
33
32
|
async function readPackage(path) {
|
|
34
33
|
try {
|
|
35
34
|
const content = await fs.promises.readFile(path, { encoding: 'utf-8' });
|
|
@@ -70,17 +69,18 @@ async function detectTasks(project_path, only) {
|
|
|
70
69
|
throw new Error('FIXME: unsupported version');
|
|
71
70
|
}
|
|
72
71
|
console.debug(`Matching versions: ${JSON.stringify(matching)}`);
|
|
72
|
+
const task_runtime = matching.runtime;
|
|
73
73
|
const running_node_version = process.versions.node;
|
|
74
74
|
let required_node_version;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.debug(`Task requires different node version: v${matching.node}`);
|
|
75
|
+
if (matching?.node && semver.major(matching.node) !== semver.major(running_node_version)) {
|
|
76
|
+
console.debug(`Task requires different node version: v${matching.node}. Running: ${running_node_version}`);
|
|
78
77
|
required_node_version = matching.node;
|
|
79
78
|
}
|
|
80
79
|
return {
|
|
81
80
|
pkg_path,
|
|
82
81
|
task_name,
|
|
83
82
|
task_version,
|
|
83
|
+
task_runtime,
|
|
84
84
|
required_node_version,
|
|
85
85
|
builder_package: matching.builder_package,
|
|
86
86
|
builder_script: matching.builder_script
|
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,gD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;YACZ,qBAAqB;YACrB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAvDD,kCAuDC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors"), exports);
|
|
18
17
|
__exportStar(require("./builder"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
|
@@ -1,11 +1,19 @@
|
|
|
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
|
+
npx_bin: string;
|
|
6
|
+
}>;
|
|
1
7
|
export declare function downloadAndInstallNode(node_version: string, destination: string): Promise<{
|
|
2
8
|
bin_path: string;
|
|
3
9
|
node_bin: string;
|
|
4
10
|
npm_bin: string;
|
|
11
|
+
npx_bin: string;
|
|
5
12
|
}>;
|
|
6
13
|
export declare function nodePaths(destination: string): {
|
|
7
14
|
bin_path: string;
|
|
8
15
|
node_bin: string;
|
|
9
16
|
npm_bin: string;
|
|
17
|
+
npx_bin: string;
|
|
10
18
|
};
|
|
11
19
|
export declare function downloadAndExtractTarball(url: string, dest: string): Promise<void>;
|
|
@@ -26,13 +26,26 @@ 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 = void 0;
|
|
30
|
-
const
|
|
29
|
+
exports.downloadAndExtractTarball = exports.nodePaths = exports.downloadAndInstallNode = exports.ensureCustomNodeVersion = void 0;
|
|
30
|
+
const jetpack = __importStar(require("fs-jetpack"));
|
|
31
31
|
const path = __importStar(require("node:path"));
|
|
32
|
+
const URL = __importStar(require("node:url"));
|
|
33
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
32
34
|
const fs = __importStar(require("node:fs"));
|
|
33
35
|
const os = __importStar(require("node:os"));
|
|
34
|
-
const URL = __importStar(require("node:url"));
|
|
35
36
|
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;
|
|
36
49
|
/* Basically this, but for different dirs.
|
|
37
50
|
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${PLATFORM}64.tar.gz -L | tar -xzC /node-dedicated && \
|
|
38
51
|
mv /node-dedicated/node-v${NODE_VERSION}-linux-${PLATFORM}64/bin/node /node-dedicated/node
|
|
@@ -40,14 +53,10 @@ const tar = __importStar(require("tar"));
|
|
|
40
53
|
// TODO: feature to find the latest minor and patch for a given major version?
|
|
41
54
|
async function downloadAndInstallNode(node_version, destination) {
|
|
42
55
|
// 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.
|
|
46
56
|
const ARCH = os.arch();
|
|
47
57
|
const PLATFORM = os.platform();
|
|
48
58
|
const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-${PLATFORM}-${ARCH}.tar.gz`;
|
|
49
59
|
await downloadAndExtractTarball(node_download_url, destination);
|
|
50
|
-
// TODO: move binaries into local bin path?
|
|
51
60
|
return nodePaths(destination);
|
|
52
61
|
}
|
|
53
62
|
exports.downloadAndInstallNode = downloadAndInstallNode;
|
|
@@ -55,7 +64,8 @@ function nodePaths(destination) {
|
|
|
55
64
|
return {
|
|
56
65
|
bin_path: path.resolve(destination, 'bin'),
|
|
57
66
|
node_bin: path.resolve(destination, 'bin', 'node'),
|
|
58
|
-
npm_bin: path.resolve(destination, 'bin', 'npm')
|
|
67
|
+
npm_bin: path.resolve(destination, 'bin', 'npm'),
|
|
68
|
+
npx_bin: path.resolve(destination, 'bin', 'npx')
|
|
59
69
|
};
|
|
60
70
|
}
|
|
61
71
|
exports.nodePaths = nodePaths;
|
|
@@ -69,19 +79,17 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
69
79
|
fs.unlinkSync(download);
|
|
70
80
|
}
|
|
71
81
|
await new Promise(async (resolve, reject) => {
|
|
72
|
-
console.
|
|
82
|
+
console.debug(`fetching ${url} into ${download}`);
|
|
73
83
|
const response = await (0, node_fetch_1.default)(url);
|
|
74
84
|
if (!response.ok) {
|
|
75
85
|
const errorBody = await response.statusText;
|
|
76
86
|
throw new Error(`Failed to download: ${errorBody}`);
|
|
77
87
|
}
|
|
78
|
-
// FIXME: replace with webstreams? but according to the types package webstreams aren't available in node 16?!??
|
|
79
88
|
const file = fs.createWriteStream(download); // Sink the download stream into a file, so it can be extracted.
|
|
80
89
|
response.body.pipe(file);
|
|
81
90
|
file.on('finish', async () => {
|
|
82
91
|
try {
|
|
83
|
-
console.
|
|
84
|
-
// const comp = fs.createReadStream(download);
|
|
92
|
+
console.debug('Extracting...', download);
|
|
85
93
|
tar.extract({
|
|
86
94
|
cwd: tmpdir,
|
|
87
95
|
file: download,
|
|
@@ -94,28 +102,29 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
94
102
|
// fs.rmSync(dist, { recursive: true });
|
|
95
103
|
// }
|
|
96
104
|
if (fs.existsSync(uncomp)) {
|
|
97
|
-
console.
|
|
105
|
+
console.debug(`Moving extracted files from ${uncomp} to ${dist}`);
|
|
98
106
|
fs.renameSync(uncomp, dist);
|
|
99
107
|
}
|
|
100
108
|
else {
|
|
101
|
-
console.
|
|
109
|
+
console.debug(`Can't find extract dir ${uncomp}`);
|
|
102
110
|
}
|
|
103
|
-
// FIXME: this seems to sometimes cause errors
|
|
104
111
|
/*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
FIXME: this seems to sometimes cause errors: eg.
|
|
113
|
+
```
|
|
114
|
+
node:events:505
|
|
115
|
+
throw er; // Unhandled 'error' event
|
|
116
|
+
^
|
|
109
117
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
Error: ENOENT: no such file or directory, open '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
119
|
+
Emitted 'error' event on ReadStream instance at:
|
|
120
|
+
at emitErrorNT (node:internal/streams/destroy:157:8)
|
|
121
|
+
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
|
|
122
|
+
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
|
|
123
|
+
errno: -2,
|
|
124
|
+
code: 'ENOENT',
|
|
125
|
+
syscall: 'open',
|
|
126
|
+
path: '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
127
|
+
```
|
|
119
128
|
*/
|
|
120
129
|
// fs.unlinkSync(file.path);
|
|
121
130
|
resolve(null);
|
|
@@ -127,4 +136,4 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
127
136
|
});
|
|
128
137
|
}
|
|
129
138
|
exports.downloadAndExtractTarball = downloadAndExtractTarball;
|
|
130
|
-
//# sourceMappingURL=
|
|
139
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,gDAAkC;AAClC,8CAAgC;AAChC,4DAA+B;AAC/B,4CAA8B;AAC9B,4CAA8B;AAC9B,yCAA2B;AAEpB,KAAK,UAAU,uBAAuB,CAAC,YAAoB,EAAE,YAAoB;IACtF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,EAAE;QACxD,OAAO,CAAC,KAAK,CAAC,SAAS,YAAY,mBAAmB,YAAY,EAAE,CAAC,CAAC;QACtE,MAAM,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,sBAAsB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;KAC1D;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,SAAS,YAAY,0BAA0B,YAAY,EAAE,CAAC,CAAC;KAC9E;IACD,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC;AATD,0DASC;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M,OAAO,IAAI,EAAE,CAAC,CAAC;oBAClE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iBAC7B;qBAAM;oBACL,OAAO,CAAC,KAAK,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC;iBACnD;gBAED;;;;;;;;;;;;;;;;;kBAiBE;gBACF,4BAA4B;gBAE5B,OAAO,CAAC,IAAI,CAAC,CAAC;aACf;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA1ED,8DA0EC"}
|
package/dist/run.d.ts
ADDED
package/dist/run.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommand = void 0;
|
|
4
|
+
const spawn_stream_1 = require("./spawn-stream");
|
|
5
|
+
async function* runCommand(command, args, options) {
|
|
6
|
+
const { childProcess, stream } = (0, spawn_stream_1.spawnStream)(command, args, { cwd: options?.cwd, splitLines: true, ...options });
|
|
7
|
+
let exitCode = null;
|
|
8
|
+
for await (let event of stream) {
|
|
9
|
+
yield event;
|
|
10
|
+
if (event.exitCode != null) {
|
|
11
|
+
exitCode = event.exitCode;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (exitCode != 0) {
|
|
15
|
+
throw new Error(`Command failed with code ${exitCode}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.runCommand = runCommand;
|
|
19
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;AAAA,iDAA+D;AAGxD,KAAK,SAAS,CAAC,CAAC,UAAU,CAC/B,OAAe,EACf,IAAc,EACd,OAA+B;IAE/B,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAW,EAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEjH,IAAI,QAAQ,GAAkB,IAAI,CAAC;IAEnC,IAAI,KAAK,EAAE,IAAI,KAAK,IAAI,MAAM,EAAE;QAC9B,MAAM,KAAK,CAAC;QACZ,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC1B,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;SAC3B;KACF;IAED,IAAI,QAAQ,IAAI,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAC;KACzD;AACH,CAAC;AAnBD,gCAmBC"}
|