@journeyapps/cloudcode-build-agent 0.0.0-dev.6fdb5b1 → 0.0.0-dev.785c29c
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 +17 -5
- package/dist/detect_tasks.js +22 -7
- 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 -33
- 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
|
+
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());
|
|
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,KAAK,EAAE;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E,GAAG,IAAI,CAAC,SAAS,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;IAEtD,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":"","s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AM,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@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;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;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
|
@@ -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' });
|
|
@@ -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,
|
|
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,17 +83,19 @@ 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
|
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
|
|
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,EAAE,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QAC/B,MAAM,GAAG,CAAC;QACV,mCAAmC;QACnC,+CAA+C;KAChD;AACH,CAAC;AAsBD,MAAM,sBAAsB,GAAG;IAC7B,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;CACd,CAAC;AAEK,KAAK,UAAU,WAAW,CAAC,YAAoB,EAAE,IAAa;IACnE,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;QACnC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KAC5B;IACD,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC/F,MAAM,sBAA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MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;QAEtC,MAAM,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnD,IAAI,qBAAqB,CAAC;QAC1B,IAAI,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE;YACxF,OAAO,CAAC,KAAK,CAAC,0CAA0C,QAAQ,CAAC,IAAI,cAAc,oBAAoB,EAAE,CAAC,CAAC;YAE3G,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC;SACvC;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;AAnED,kCAmEC"}
|
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>;
|