@journeyapps/cloudcode-build-agent 0.0.0-dev.8ebefb0 → 0.0.0-dev.9117f43
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 +66 -67
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +7 -2
- package/dist/cli.js.map +1 -1
- package/dist/defs.d.ts +1 -0
- package/dist/defs.js +20 -26
- package/dist/defs.js.map +1 -1
- package/dist/detect_tasks.d.ts +17 -5
- package/dist/detect_tasks.js +23 -9
- package/dist/detect_tasks.js.map +1 -1
- package/dist/installer.d.ts +8 -0
- package/dist/installer.js +39 -34
- package/dist/installer.js.map +1 -1
- package/dist/run.d.ts +0 -1
- package/dist/run.js +1 -2
- package/dist/run.js.map +1 -1
- package/dist/spawn-stream.d.ts +0 -1
- package/dist/spawn-stream.js +1 -2
- package/dist/spawn-stream.js.map +1 -1
- package/package.json +19 -13
- package/src/builder.ts +0 -105
- package/src/cli.ts +0 -51
- package/src/defs.ts +0 -45
- package/src/detect_tasks.ts +0 -74
- package/src/index.ts +0 -1
- package/src/installer.ts +0 -112
- package/src/run.ts +0 -23
- package/src/spawn-stream.ts +0 -73
- package/tsconfig.json +0 -8
- 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,89 +23,88 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.buildTasks =
|
|
26
|
+
exports.buildTasks = buildTasks;
|
|
27
|
+
exports.buildTask = buildTask;
|
|
27
28
|
const path = __importStar(require("node:path"));
|
|
28
29
|
const jetpack = __importStar(require("fs-jetpack"));
|
|
29
30
|
const semver = __importStar(require("semver"));
|
|
30
|
-
const
|
|
31
|
+
const installer_1 = require("./installer");
|
|
31
32
|
const detect_tasks_1 = require("./detect_tasks");
|
|
32
33
|
const run_1 = require("./run");
|
|
33
|
-
|
|
34
|
-
|
|
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 = {};
|
|
34
|
+
async function buildTasks(project_path, dest, config, options) {
|
|
35
|
+
const tasks = await (0, detect_tasks_1.detectTasks)(project_path, options?.only);
|
|
40
36
|
// Use the version of nodejs that's running this script as the default.
|
|
41
37
|
const default_tool_paths = {
|
|
42
38
|
bin_path: path.dirname(process.execPath),
|
|
43
39
|
node_bin: process.execPath,
|
|
44
|
-
npm_bin: path.join(path.dirname(process.execPath), 'npm')
|
|
40
|
+
npm_bin: path.join(path.dirname(process.execPath), 'npm'),
|
|
41
|
+
npx_bin: path.join(path.dirname(process.execPath), 'npx')
|
|
45
42
|
};
|
|
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);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
console.debug(`already installed in ${custom_node_path}`);
|
|
57
|
-
}
|
|
58
|
-
tool_paths[required_node_version] = utils.nodePaths(custom_node_path);
|
|
59
|
-
}
|
|
60
|
-
// console.debug('----');
|
|
61
43
|
for (const task of tasks) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw new Error(`Node binary not found: ${node_bin}`);
|
|
44
|
+
let custom_tool_paths;
|
|
45
|
+
if (task.required_node_version) {
|
|
46
|
+
// FIXME: when defaulting to project_path, the custom node installation is copied into the builder's workdir as well.
|
|
47
|
+
const custom_node_installation_path = options?.custom_node_installation_path ?? project_path;
|
|
48
|
+
const custom_node_path = path.resolve(custom_node_installation_path, `node-${semver.major(task.required_node_version)}`);
|
|
49
|
+
custom_tool_paths = await (0, installer_1.ensureCustomNodeVersion)(task.required_node_version, custom_node_path);
|
|
69
50
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
env: process.env
|
|
51
|
+
const node_version = task.required_node_version ?? process.version;
|
|
52
|
+
await buildTask(task, project_path, dest, config, {
|
|
53
|
+
node_version,
|
|
54
|
+
...(custom_tool_paths ?? default_tool_paths)
|
|
75
55
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
}
|
|
57
|
+
}
|
|
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', // Suppress noisy "WARN" messages.
|
|
74
|
+
...process.env
|
|
81
75
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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());
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
}
|
|
83
|
+
const build_metadata = {
|
|
84
|
+
name: task.task_name,
|
|
85
|
+
version: task.task_version,
|
|
86
|
+
lambda_runtime: task.task_runtime,
|
|
87
|
+
user_config: task.user_task_config
|
|
88
|
+
};
|
|
89
|
+
await jetpack.writeAsync(path.join(dest, `${task.task_name}-metadata.json`), JSON.stringify(build_metadata));
|
|
90
|
+
const builder_args = [];
|
|
91
|
+
builder_args.push(builder_script);
|
|
92
|
+
builder_args.push('--src', project_path);
|
|
93
|
+
builder_args.push(`--out`, path.join(dest, task.task_name));
|
|
94
|
+
builder_args.push(`--zip`, path.join(dest, `${task.task_name}.zip`));
|
|
95
|
+
builder_args.push(`--task`, `${task.task_name}`);
|
|
96
|
+
builder_args.push(`--appId`, config.app_id);
|
|
97
|
+
builder_args.push(`--env`, config.env);
|
|
98
|
+
builder_args.push(`--backendId`, config.backend_id);
|
|
99
|
+
builder_args.push(`--backendUrl`, config.backend_url);
|
|
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());
|
|
106
106
|
}
|
|
107
|
-
// console.debug('----');
|
|
108
107
|
}
|
|
108
|
+
console.log(`[${task.task_name} - build]`, `Finished.`);
|
|
109
109
|
}
|
|
110
|
-
exports.buildTasks = buildTasks;
|
|
111
110
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,gCAkCC;AAED,8BAoEC;AAhID,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AAEjC,2CAAsD;AACtD,iDA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,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEhH,IAAI,KAAK,EAAE,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACzC,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,WAAW,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,WAAW,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC"}
|
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',
|
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,yBAAgC;AAEhC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,gBAAgB,GAAG,
|
|
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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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
|
-
node: '16.19.1',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
builder_package: '~/src/journey-cloudcode/packages/cloudcode-build-legacy',
|
|
16
|
+
node: '16.19.1', // FIXME: maybe the very specific node version here is too brittle? Should we just specify the major version?
|
|
17
|
+
runtime: 'nodejs16.x',
|
|
18
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0-alpha.1',
|
|
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@1.12.0-alpha.1',
|
|
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@1.12.0-alpha.1',
|
|
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@1.12.0-alpha.1',
|
|
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,EAAE,6GAA6G;QAC9H,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;CACF,CAAC"}
|
package/dist/detect_tasks.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
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
|
+
user_task_config: {
|
|
10
|
+
runtime: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
shared?: boolean;
|
|
13
|
+
serial?: boolean;
|
|
14
|
+
app?: boolean;
|
|
15
|
+
web?: boolean;
|
|
16
|
+
webhook?: boolean;
|
|
17
|
+
schedule?: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function detectTasks(project_path: string, only?: string): Promise<DetectedTask[]>;
|
package/dist/detect_tasks.js
CHANGED
|
@@ -23,13 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.detectTasks =
|
|
26
|
+
exports.detectTasks = detectTasks;
|
|
27
27
|
const fs = __importStar(require("node:fs"));
|
|
28
28
|
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' });
|
|
@@ -42,8 +41,16 @@ async function readPackage(path) {
|
|
|
42
41
|
// todo: if json error, throw a CC build error?
|
|
43
42
|
}
|
|
44
43
|
}
|
|
44
|
+
const UserTaskConfigDefaults = {
|
|
45
|
+
runtime: null, // Required field, but could be missing in ancient versions
|
|
46
|
+
enabled: true
|
|
47
|
+
};
|
|
45
48
|
async function detectTasks(project_path, only) {
|
|
46
|
-
const
|
|
49
|
+
const cloudcode_path = path.join(project_path, 'cloudcode');
|
|
50
|
+
if (!jetpack.exists(cloudcode_path)) {
|
|
51
|
+
return Promise.resolve([]);
|
|
52
|
+
}
|
|
53
|
+
const package_files = await jetpack.findAsync(cloudcode_path, { matching: '**/package.json' });
|
|
47
54
|
const filtered_package_files = package_files.filter((pkg_path) => {
|
|
48
55
|
// FIXME: this is kinda clunky.
|
|
49
56
|
const pm = /^\/?cloudcode\/([^\/]+)\/package\.json$/.exec(pkg_path);
|
|
@@ -60,8 +67,14 @@ async function detectTasks(project_path, only) {
|
|
|
60
67
|
return Promise.all(filtered_package_files.map(async (pkg_path) => {
|
|
61
68
|
const task_package = await readPackage(pkg_path);
|
|
62
69
|
const task_name = task_package.name; // CAVEAT: the pkg name _must_ match the dir.
|
|
63
|
-
const task_version = task_package
|
|
64
|
-
|
|
70
|
+
const task_version = task_package.cloudcode.runtime;
|
|
71
|
+
const user_task_config = {
|
|
72
|
+
...UserTaskConfigDefaults,
|
|
73
|
+
...task_package.cloud_code
|
|
74
|
+
};
|
|
75
|
+
/* CAVEAT: We do not exclude disabled tasks from the build process, because this is a special case where the
|
|
76
|
+
processing for a task is disabled, but the resources for the task are not destroyed.
|
|
77
|
+
*/
|
|
65
78
|
console.debug(`Detected task version ${task_version}`);
|
|
66
79
|
const matching = defs.SUPPORTED_VERSIONS.find((v) => {
|
|
67
80
|
return semver.satisfies(v.version, task_version);
|
|
@@ -70,22 +83,23 @@ async function detectTasks(project_path, only) {
|
|
|
70
83
|
throw new Error('FIXME: unsupported version');
|
|
71
84
|
}
|
|
72
85
|
console.debug(`Matching versions: ${JSON.stringify(matching)}`);
|
|
86
|
+
const task_runtime = matching.runtime;
|
|
73
87
|
const running_node_version = process.versions.node;
|
|
74
88
|
let required_node_version;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.debug(`Task requires different node version: v${matching.node}`);
|
|
89
|
+
if (matching?.node && semver.major(matching.node) !== semver.major(running_node_version)) {
|
|
90
|
+
console.debug(`Task requires different node version: v${matching.node}. Running: ${running_node_version}`);
|
|
78
91
|
required_node_version = matching.node;
|
|
79
92
|
}
|
|
80
93
|
return {
|
|
81
94
|
pkg_path,
|
|
82
95
|
task_name,
|
|
83
96
|
task_version,
|
|
97
|
+
task_runtime,
|
|
98
|
+
user_task_config,
|
|
84
99
|
required_node_version,
|
|
85
100
|
builder_package: matching.builder_package,
|
|
86
101
|
builder_script: matching.builder_script
|
|
87
102
|
};
|
|
88
103
|
}));
|
|
89
104
|
}
|
|
90
|
-
exports.detectTasks = detectTasks;
|
|
91
105
|
//# sourceMappingURL=detect_tasks.js.map
|
package/dist/detect_tasks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect_tasks.js","sourceRoot":"","sources":["../src/detect_tasks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detect_tasks.js","sourceRoot":"","sources":["../src/detect_tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,kCAmEC;AA9GD,4CAA8B;AAC9B,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AACjC,6CAA+B;AAE/B,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,IAAI,CAAC;QACH,MAAM,OAAO,G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AC;YAE3G,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC;QACxC,CAAC;QACD,OAAO;YACL,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,YAAY;YACZ,gBAAgB;YAChB,qBAAqB;YACrB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/installer.d.ts
CHANGED
|
@@ -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>;
|
package/dist/installer.js
CHANGED
|
@@ -26,13 +26,28 @@ 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.
|
|
30
|
-
|
|
29
|
+
exports.ensureCustomNodeVersion = ensureCustomNodeVersion;
|
|
30
|
+
exports.downloadAndInstallNode = downloadAndInstallNode;
|
|
31
|
+
exports.nodePaths = nodePaths;
|
|
32
|
+
exports.downloadAndExtractTarball = downloadAndExtractTarball;
|
|
33
|
+
const jetpack = __importStar(require("fs-jetpack"));
|
|
31
34
|
const path = __importStar(require("node:path"));
|
|
35
|
+
const URL = __importStar(require("node:url"));
|
|
36
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
32
37
|
const fs = __importStar(require("node:fs"));
|
|
33
38
|
const os = __importStar(require("node:os"));
|
|
34
|
-
const URL = __importStar(require("node:url"));
|
|
35
39
|
const tar = __importStar(require("tar"));
|
|
40
|
+
async function ensureCustomNodeVersion(node_version, install_path) {
|
|
41
|
+
if (!jetpack.exists(path.join(install_path, 'bin/node'))) {
|
|
42
|
+
console.debug(`[node ${node_version}] Installing to ${install_path}`);
|
|
43
|
+
await jetpack.dirAsync(install_path);
|
|
44
|
+
await downloadAndInstallNode(node_version, install_path);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.debug(`[node ${node_version}] Already installed in ${install_path}`);
|
|
48
|
+
}
|
|
49
|
+
return nodePaths(install_path);
|
|
50
|
+
}
|
|
36
51
|
/* Basically this, but for different dirs.
|
|
37
52
|
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${PLATFORM}64.tar.gz -L | tar -xzC /node-dedicated && \
|
|
38
53
|
mv /node-dedicated/node-v${NODE_VERSION}-linux-${PLATFORM}64/bin/node /node-dedicated/node
|
|
@@ -40,25 +55,20 @@ const tar = __importStar(require("tar"));
|
|
|
40
55
|
// TODO: feature to find the latest minor and patch for a given major version?
|
|
41
56
|
async function downloadAndInstallNode(node_version, destination) {
|
|
42
57
|
// 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
58
|
const ARCH = os.arch();
|
|
47
59
|
const PLATFORM = os.platform();
|
|
48
60
|
const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-${PLATFORM}-${ARCH}.tar.gz`;
|
|
49
61
|
await downloadAndExtractTarball(node_download_url, destination);
|
|
50
|
-
// TODO: move binaries into local bin path?
|
|
51
62
|
return nodePaths(destination);
|
|
52
63
|
}
|
|
53
|
-
exports.downloadAndInstallNode = downloadAndInstallNode;
|
|
54
64
|
function nodePaths(destination) {
|
|
55
65
|
return {
|
|
56
66
|
bin_path: path.resolve(destination, 'bin'),
|
|
57
67
|
node_bin: path.resolve(destination, 'bin', 'node'),
|
|
58
|
-
npm_bin: path.resolve(destination, 'bin', 'npm')
|
|
68
|
+
npm_bin: path.resolve(destination, 'bin', 'npm'),
|
|
69
|
+
npx_bin: path.resolve(destination, 'bin', 'npx')
|
|
59
70
|
};
|
|
60
71
|
}
|
|
61
|
-
exports.nodePaths = nodePaths;
|
|
62
72
|
async function downloadAndExtractTarball(url, dest) {
|
|
63
73
|
const tmpdir = os.tmpdir();
|
|
64
74
|
const filename = path.basename(URL.parse(url).pathname);
|
|
@@ -69,7 +79,7 @@ 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;
|
|
@@ -79,8 +89,7 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
79
89
|
response.body.pipe(file);
|
|
80
90
|
file.on('finish', async () => {
|
|
81
91
|
try {
|
|
82
|
-
console.
|
|
83
|
-
// const comp = fs.createReadStream(download);
|
|
92
|
+
console.debug('Extracting...', download);
|
|
84
93
|
tar.extract({
|
|
85
94
|
cwd: tmpdir,
|
|
86
95
|
file: download,
|
|
@@ -88,33 +97,30 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
88
97
|
});
|
|
89
98
|
const uncomp = path.join(tmpdir, base);
|
|
90
99
|
const dist = path.resolve(dest);
|
|
91
|
-
// FIXME: dangerous. Add protection or replace.
|
|
92
|
-
// if (fs.existsSync(dist)) {
|
|
93
|
-
// fs.rmSync(dist, { recursive: true });
|
|
94
|
-
// }
|
|
95
100
|
if (fs.existsSync(uncomp)) {
|
|
96
|
-
console.
|
|
101
|
+
console.debug(`Moving extracted files from ${uncomp} to ${dist}`);
|
|
97
102
|
fs.renameSync(uncomp, dist);
|
|
98
103
|
}
|
|
99
104
|
else {
|
|
100
|
-
console.
|
|
105
|
+
console.debug(`Can't find extract dir ${uncomp}`);
|
|
101
106
|
}
|
|
102
|
-
// FIXME: this seems to sometimes cause errors
|
|
103
107
|
/*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
FIXME: the unlinking seems to sometimes cause errors: eg.
|
|
109
|
+
```
|
|
110
|
+
node:events:505
|
|
111
|
+
throw er; // Unhandled 'error' event
|
|
112
|
+
^
|
|
108
113
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
Error: ENOENT: no such file or directory, open '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
115
|
+
Emitted 'error' event on ReadStream instance at:
|
|
116
|
+
at emitErrorNT (node:internal/streams/destroy:157:8)
|
|
117
|
+
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
|
|
118
|
+
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
|
|
119
|
+
errno: -2,
|
|
120
|
+
code: 'ENOENT',
|
|
121
|
+
syscall: 'open',
|
|
122
|
+
path: '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
123
|
+
```
|
|
118
124
|
*/
|
|
119
125
|
// fs.unlinkSync(file.path);
|
|
120
126
|
resolve(null);
|
|
@@ -125,5 +131,4 @@ async function downloadAndExtractTarball(url, dest) {
|
|
|
125
131
|
});
|
|
126
132
|
});
|
|
127
133
|
}
|
|
128
|
-
exports.downloadAndExtractTarball = downloadAndExtractTarball;
|
|
129
134
|
//# sourceMappingURL=installer.js.map
|