@lage-run/scheduler
Advanced tools
Comparing version 0.5.9 to 0.5.10
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Wed, 02 Nov 2022 20:44:52 GMT", | ||
"date": "Fri, 04 Nov 2022 21:13:54 GMT", | ||
"tag": "@lage-run/scheduler_v0.5.10", | ||
"version": "0.5.10", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"author": "kchau@microsoft.com", | ||
"package": "@lage-run/scheduler", | ||
"commit": "6dba6df4c699c92ca201e91301dfa4aac6344902", | ||
"comment": "fixed the tsconfig.lage2.json to output node16 moduleRes" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Wed, 02 Nov 2022 20:45:00 GMT", | ||
"tag": "@lage-run/scheduler_v0.5.9", | ||
@@ -8,0 +23,0 @@ "version": "0.5.9", |
# Change Log - @lage-run/scheduler | ||
This log was last generated on Wed, 02 Nov 2022 20:44:52 GMT and should not be manually modified. | ||
This log was last generated on Fri, 04 Nov 2022 21:13:54 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.5.10 | ||
Fri, 04 Nov 2022 21:13:54 GMT | ||
### Patches | ||
- fixed the tsconfig.lage2.json to output node16 moduleRes (kchau@microsoft.com) | ||
## 0.5.9 | ||
Wed, 02 Nov 2022 20:44:52 GMT | ||
Wed, 02 Nov 2022 20:45:00 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -36,7 +36,6 @@ "use strict"; | ||
async hasNpmScript(target) { | ||
var _a; | ||
const { task } = target; | ||
const packageJsonPath = (0, path_1.join)(target.cwd, "package.json"); | ||
const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, "utf8")); | ||
return (_a = packageJson.scripts) === null || _a === void 0 ? void 0 : _a[task]; | ||
return packageJson.scripts?.[task]; | ||
} | ||
@@ -49,3 +48,2 @@ validateOptions(options) { | ||
async run(runOptions) { | ||
var _a; | ||
const { target, weight, abortSignal } = runOptions; | ||
@@ -90,3 +88,3 @@ const { nodeOptions, npmCmd, taskArgs } = this.options; | ||
const npmRunArgs = this.getNpmArgs(target.task, taskArgs); | ||
const npmRunNodeOptions = [nodeOptions, (_a = target.options) === null || _a === void 0 ? void 0 : _a.nodeOptions].filter((str) => str).join(" "); | ||
const npmRunNodeOptions = [nodeOptions, target.options?.nodeOptions].filter((str) => str).join(" "); | ||
await new Promise((resolve, reject) => { | ||
@@ -107,5 +105,4 @@ childProcess = (0, child_process_1.spawn)(npmCmd, npmRunArgs, { | ||
const handleChildProcessExit = (code) => { | ||
var _a, _b, _c; | ||
childProcess === null || childProcess === void 0 ? void 0 : childProcess.off("exit", handleChildProcessExit); | ||
childProcess === null || childProcess === void 0 ? void 0 : childProcess.off("error", handleChildProcessExit); | ||
childProcess?.off("exit", handleChildProcessExit); | ||
childProcess?.off("error", handleChildProcessExit); | ||
if (exitHandled) { | ||
@@ -115,5 +112,5 @@ return; | ||
exitHandled = true; | ||
(_a = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdout) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
(_b = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stderr) === null || _b === void 0 ? void 0 : _b.destroy(); | ||
(_c = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdin) === null || _c === void 0 ? void 0 : _c.destroy(); | ||
childProcess?.stdout?.destroy(); | ||
childProcess?.stderr?.destroy(); | ||
childProcess?.stdin?.destroy(); | ||
if (code === 0) { | ||
@@ -120,0 +117,0 @@ return resolve(); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -32,3 +9,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const target_graph_1 = require("@lage-run/target-graph"); | ||
const NoOpRunner_js_1 = require("./NoOpRunner.js"); | ||
class TargetRunnerPicker { | ||
@@ -40,3 +16,3 @@ constructor(options) { | ||
if (target.id === (0, target_graph_1.getStartTargetId)()) { | ||
return NoOpRunner_js_1.NoOpRunner; | ||
return (await import("./NoOpRunner.js")).NoOpRunner; | ||
} | ||
@@ -49,3 +25,3 @@ if (!target.type) { | ||
const { script, options } = config; | ||
const runnerModule = await Promise.resolve().then(() => __importStar(require(script))); | ||
const runnerModule = await import(script); | ||
const base = path_1.default.basename(script); | ||
@@ -52,0 +28,0 @@ const runnerName = base.replace(path_1.default.extname(base), ""); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -67,10 +44,9 @@ exports.WorkerRunner = void 0; | ||
async run(runOptions) { | ||
var _a, _b, _c; | ||
const { target, weight, abortSignal } = runOptions; | ||
const { taskArgs } = this.options; | ||
const scriptFile = (_b = (_a = target.options) === null || _a === void 0 ? void 0 : _a.worker) !== null && _b !== void 0 ? _b : (_c = target.options) === null || _c === void 0 ? void 0 : _c.script; | ||
const scriptFile = target.options?.worker ?? target.options?.script; | ||
if (!scriptFile) { | ||
throw new Error('WorkerRunner: "script" configuration is required - e.g. { type: "worker", script: "./worker.js" }'); | ||
} | ||
const scriptModule = await Promise.resolve().then(() => __importStar(require(scriptFile))); | ||
const scriptModule = await import(scriptFile); | ||
const runFn = typeof scriptModule.default === "function" ? scriptModule.default : scriptModule; | ||
@@ -77,0 +53,0 @@ if (typeof runFn !== "function") { |
@@ -23,3 +23,2 @@ "use strict"; | ||
constructor(options) { | ||
var _a; | ||
this.options = options; | ||
@@ -33,17 +32,18 @@ this.targetRuns = new Map(); | ||
this.pool = | ||
(_a = options.pool) !== null && _a !== void 0 ? _a : new worker_threads_pool_1.AggregatedPool({ | ||
logger: options.logger, | ||
maxWorkersByGroup: options.maxWorkersPerTask, | ||
groupBy: ({ target }) => target.task, | ||
maxWorkers: options.concurrency, | ||
script: require.resolve("./workers/targetWorker"), | ||
workerOptions: { | ||
stdout: true, | ||
stderr: true, | ||
workerData: { | ||
runners: options.runners, | ||
options.pool ?? | ||
new worker_threads_pool_1.AggregatedPool({ | ||
logger: options.logger, | ||
maxWorkersByGroup: options.maxWorkersPerTask, | ||
groupBy: ({ target }) => target.task, | ||
maxWorkers: options.concurrency, | ||
script: require.resolve("./workers/targetWorker"), | ||
workerOptions: { | ||
stdout: true, | ||
stderr: true, | ||
workerData: { | ||
runners: options.runners, | ||
}, | ||
}, | ||
}, | ||
workerIdleMemoryLimit: options.workerIdleMemoryLimit, // in bytes | ||
}); | ||
workerIdleMemoryLimit: options.workerIdleMemoryLimit, // in bytes | ||
}); | ||
} | ||
@@ -145,3 +145,2 @@ /** | ||
getReadyTargets() { | ||
var _a; | ||
const readyTargets = []; | ||
@@ -167,3 +166,3 @@ const runningTargets = this.targetsByPriority.filter((target) => this.targetRuns.get(target.id).status === "running"); | ||
readyTargets.push(targetRun); | ||
runningTargetsCountByTask[target.task] = ((_a = runningTargetsCountByTask[target.task]) !== null && _a !== void 0 ? _a : 0) + 1; | ||
runningTargetsCountByTask[target.task] = (runningTargetsCountByTask[target.task] ?? 0) + 1; | ||
} | ||
@@ -194,6 +193,5 @@ } | ||
.catch((e) => { | ||
var _a; | ||
// if a continue option is set, this merely records what errors have been encountered | ||
// it'll continue down the execution until all the tasks that still works | ||
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.continueOnError) { | ||
if (this.options?.continueOnError) { | ||
return this.scheduleReadyTargets(); | ||
@@ -200,0 +198,0 @@ } |
@@ -120,3 +120,3 @@ "use strict"; | ||
this.onStart(); | ||
const cachedOutputFile = (0, getLageOutputCacheLocation_js_1.getLageOutputCacheLocation)(this.target, hash !== null && hash !== void 0 ? hash : ""); | ||
const cachedOutputFile = (0, getLageOutputCacheLocation_js_1.getLageOutputCacheLocation)(this.target, hash ?? ""); | ||
if (fs_1.default.existsSync(cachedOutputFile)) { | ||
@@ -162,3 +162,2 @@ const cachedOutput = fs_1.default.createReadStream(cachedOutputFile, "utf8"); | ||
async runInPool() { | ||
var _a; | ||
const { target, logger, abortController, pool } = this.options; | ||
@@ -170,3 +169,3 @@ const abortSignal = abortController.signal; | ||
const bufferStderr = (0, bufferTransform_js_1.bufferTransform)(); | ||
await pool.exec({ target }, (_a = target.weight) !== null && _a !== void 0 ? _a : 1, (_worker, stdout, stderr) => { | ||
await pool.exec({ target }, target.weight ?? 1, (_worker, stdout, stderr) => { | ||
this.onStart(); | ||
@@ -173,0 +172,0 @@ stdout.pipe(bufferStdout.transform); |
{ | ||
"name": "@lage-run/scheduler", | ||
"version": "0.5.9", | ||
"version": "0.5.10", | ||
"description": "Scheduler for Lage", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6
111043
2269