@lage-run/cli 0.1.1
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/CHANGELOG.json +44 -0
- package/CHANGELOG.md +17 -0
- package/README.md +9 -0
- package/bin/lage.js +3 -0
- package/jest.config.js +1 -0
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +13 -0
- package/lib/cli.js.map +1 -0
- package/lib/commands/run/index.d.ts +3 -0
- package/lib/commands/run/index.js +96 -0
- package/lib/commands/run/index.js.map +1 -0
- package/lib/commands/run/runAction.d.ts +2 -0
- package/lib/commands/run/runAction.js +139 -0
- package/lib/commands/run/runAction.js.map +1 -0
- package/lib/config/getConfig.d.ts +2 -0
- package/lib/config/getConfig.js +34 -0
- package/lib/config/getConfig.js.map +1 -0
- package/lib/createReporter.d.ts +8 -0
- package/lib/createReporter.js +18 -0
- package/lib/createReporter.js.map +1 -0
- package/lib/filter/getFilteredPackages.d.ts +20 -0
- package/lib/filter/getFilteredPackages.js +117 -0
- package/lib/filter/getFilteredPackages.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/types/CacheOptions.d.ts +7 -0
- package/lib/types/CacheOptions.js +3 -0
- package/lib/types/CacheOptions.js.map +1 -0
- package/lib/types/ConfigOptions.d.ts +38 -0
- package/lib/types/ConfigOptions.js +3 -0
- package/lib/types/ConfigOptions.js.map +1 -0
- package/lib/types/LoggerOptions.d.ts +15 -0
- package/lib/types/LoggerOptions.js +3 -0
- package/lib/types/LoggerOptions.js.map +1 -0
- package/lib/types/PipelineDefinition.d.ts +12 -0
- package/lib/types/PipelineDefinition.js +3 -0
- package/lib/types/PipelineDefinition.js.map +1 -0
- package/lib/types/Priority.d.ts +8 -0
- package/lib/types/Priority.js +3 -0
- package/lib/types/Priority.js.map +1 -0
- package/lib/workspace/findNpmClient.d.ts +1 -0
- package/lib/workspace/findNpmClient.js +31 -0
- package/lib/workspace/findNpmClient.js.map +1 -0
- package/package.json +39 -0
- package/tsconfig.json +23 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lage-run/cli",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Tue, 23 Aug 2022 07:53:38 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.1.1",
|
|
7
|
+
"version": "0.1.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "ken@gizzar.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "8fb3883281416a778e6528038a6b1d63749ae2dd",
|
|
14
|
+
"comment": "New package - patch bump to get it deployed!"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@lage-run/cli",
|
|
19
|
+
"comment": "Bump @lage-run/logger to v1.1.2",
|
|
20
|
+
"commit": "8fb3883281416a778e6528038a6b1d63749ae2dd"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@lage-run/cli",
|
|
25
|
+
"comment": "Bump @lage-run/scheduler to v0.1.3",
|
|
26
|
+
"commit": "8fb3883281416a778e6528038a6b1d63749ae2dd"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@lage-run/cli",
|
|
31
|
+
"comment": "Bump @lage-run/cache to v0.1.3",
|
|
32
|
+
"commit": "8fb3883281416a778e6528038a6b1d63749ae2dd"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@lage-run/cli",
|
|
37
|
+
"comment": "Bump @lage-run/reporters to v0.1.2",
|
|
38
|
+
"commit": "8fb3883281416a778e6528038a6b1d63749ae2dd"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Change Log - @lage-run/cli
|
|
2
|
+
|
|
3
|
+
This log was last generated on Tue, 23 Aug 2022 07:53:38 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 0.1.1
|
|
8
|
+
|
|
9
|
+
Tue, 23 Aug 2022 07:53:38 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- New package - patch bump to get it deployed! (ken@gizzar.com)
|
|
14
|
+
- Bump @lage-run/logger to v1.1.2
|
|
15
|
+
- Bump @lage-run/scheduler to v0.1.3
|
|
16
|
+
- Bump @lage-run/cache to v0.1.3
|
|
17
|
+
- Bump @lage-run/reporters to v0.1.2
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @lage-run/cli
|
|
2
|
+
|
|
3
|
+
This is the command line interface (CLI) for lage. It contains the logic to tie everything together:
|
|
4
|
+
|
|
5
|
+
1. parses CLI arguments via `commander`
|
|
6
|
+
2. initializes the various commands
|
|
7
|
+
3. for running the targets, there are some reserved options for lage, but the rest are passed through to the scripts
|
|
8
|
+
4. figures out the filtered packages as entry points (dependencies are also run, unless --no-dependents are specified)
|
|
9
|
+
5. scheduler, reporter, cache, logger are initialized and run
|
package/bin/lage.js
ADDED
package/jest.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("monorepo-scripts/config/jest.config.js");
|
package/lib/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const run_1 = require("./commands/run");
|
|
5
|
+
async function main() {
|
|
6
|
+
const program = new commander_1.Command();
|
|
7
|
+
program.addCommand(run_1.runCommand, { isDefault: true });
|
|
8
|
+
await program.parseAsync(process.argv);
|
|
9
|
+
}
|
|
10
|
+
main().catch((err) => {
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AAEpC,wCAA4C;AAE5C,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,UAAU,CAAC,gBAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const runAction_1 = require("./runAction");
|
|
10
|
+
const runCommand = new commander_1.Command("run");
|
|
11
|
+
exports.runCommand = runCommand;
|
|
12
|
+
runCommand
|
|
13
|
+
.action(runAction_1.runAction)
|
|
14
|
+
.option("-c, --concurrency <n>", "concurrency", (value) => {
|
|
15
|
+
if (value.endsWith("%")) {
|
|
16
|
+
return (parseInt(value.slice(0, -1)) / 100) * os_1.default.cpus().length;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return parseInt(value) || os_1.default.cpus().length - 1;
|
|
20
|
+
}
|
|
21
|
+
}, os_1.default.cpus().length - 1)
|
|
22
|
+
// Common Options
|
|
23
|
+
.option("--reporter <reporter...>", "reporter", "npmLog")
|
|
24
|
+
.option("--scope <scope...>", "scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)")
|
|
25
|
+
.option("--no-dependents|--no-deps", "disables running any dependents of the scoped packages")
|
|
26
|
+
.option("--dependencies|--include-dependencies", 'adds the scoped packages dependencies as the "entry points" for the target graph run')
|
|
27
|
+
.option("--since <since>", "only runs packages that have changed since the given commit, tag, or branch")
|
|
28
|
+
.option("--to <scope...>", "runs up to a package (shorthand for --scope=<scope...> --no-dependents)")
|
|
29
|
+
.addOption(new commander_1.Option("--log-level <level>", "log level").choices(["info", "warn", "error", "verbose", "silly"]).conflicts("--verbose"))
|
|
30
|
+
.option("--verbose", "verbose output")
|
|
31
|
+
// Run Command Options
|
|
32
|
+
.option("--grouped", "groups the logs", false)
|
|
33
|
+
.option("--no-cache", "disables the cache")
|
|
34
|
+
.option("--reset-cache", "resets the cache, filling it after a run")
|
|
35
|
+
.option("--skip-local-cache", "skips caching locally")
|
|
36
|
+
.option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool")
|
|
37
|
+
.option("--nodearg <nodeArg...>", "arguments to be passed to node (e.g. --nodearg=--max_old_space_size=1234 --nodearg=--heap-prof")
|
|
38
|
+
.option("--continue", "continues the run even on error")
|
|
39
|
+
.allowUnknownOption(true)
|
|
40
|
+
.addHelpCommand("[run] command1 [command2...commandN] [options]", "run commands")
|
|
41
|
+
.addHelpText("after", `
|
|
42
|
+
Runs a set of commands in a target graph. The targets are defined by packages and their scripts as defined the package.json files.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
========
|
|
46
|
+
|
|
47
|
+
### Basic case, running "build", "test", and "lint" against all packages
|
|
48
|
+
|
|
49
|
+
$ lage build test lint
|
|
50
|
+
|
|
51
|
+
### Concurrency
|
|
52
|
+
|
|
53
|
+
$ lage build test lint --concurrency=4
|
|
54
|
+
|
|
55
|
+
### Filtering by certain packages
|
|
56
|
+
|
|
57
|
+
Scoped to "package-a" and "package-b" and their dependencies and dependents:
|
|
58
|
+
|
|
59
|
+
$ lage build test lint --scope package-a package-b
|
|
60
|
+
|
|
61
|
+
Scoped to "package-a" and "package-b" only:
|
|
62
|
+
|
|
63
|
+
$ lage build test lint --scope package-a package-b --no-deps
|
|
64
|
+
|
|
65
|
+
Scoped to packages that have changed in the current branch against a target merge branch:
|
|
66
|
+
|
|
67
|
+
$ lage build test lint --since origin/master
|
|
68
|
+
|
|
69
|
+
### Providing node.js arguments for each command
|
|
70
|
+
|
|
71
|
+
$ lage build test lint --nodearg=--max_old_space_size=1234 --nodearg=--heap-prof
|
|
72
|
+
|
|
73
|
+
### Continue running even after encountering an error for one of the targets
|
|
74
|
+
|
|
75
|
+
$ lage build test lint --continue
|
|
76
|
+
|
|
77
|
+
### Controlling logged outputs
|
|
78
|
+
|
|
79
|
+
Show verbose output for each target:
|
|
80
|
+
|
|
81
|
+
$ lage build test lint --verbose
|
|
82
|
+
|
|
83
|
+
Show only errors for each target:
|
|
84
|
+
|
|
85
|
+
$ lage build test lint --log-level=error
|
|
86
|
+
|
|
87
|
+
Show logs as grouped by each target:
|
|
88
|
+
|
|
89
|
+
$ lage build test lint --grouped --verbose
|
|
90
|
+
|
|
91
|
+
Choosing a different reporter while logging (e.g. nice outputs for Azure DevOps):
|
|
92
|
+
|
|
93
|
+
$ lage build test lint --reporter=azureDevOps
|
|
94
|
+
|
|
95
|
+
`);
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/run/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA4C;AAC5C,4CAA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C,YAAY,EAAE,oBAAoB,CAAC;KAC1C,MAAM,CAAC,eAAe,EAAE,0CAA0C,CAAC;KACnE,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC;KAErD,MAAM,CAAC,qBAAqB,EAAE,4EAA4E,CAAC;KAC3G,MAAM,CAAC,wBAAwB,EAAE,gGAAgG,CAAC;KAClI,MAAM,CAAC,YAAY,EAAE,iCAAiC,CAAC;KAEvD,kBAAkB,CAAC,IAAI,CAAC;KACxB,cAAc,CAAC,gDAAgD,EAAE,cAAc,CAAC;KAChF,WAAW,CACV,OAAO,EACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDH,CACE,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.runAction = void 0;
|
|
27
|
+
const cache_1 = require("@lage-run/cache");
|
|
28
|
+
const findNpmClient_1 = require("../../workspace/findNpmClient");
|
|
29
|
+
const getConfig_1 = require("../../config/getConfig");
|
|
30
|
+
const getFilteredPackages_1 = require("../../filter/getFilteredPackages");
|
|
31
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
32
|
+
const createReporter_1 = require("../../createReporter");
|
|
33
|
+
const scheduler_1 = require("@lage-run/scheduler");
|
|
34
|
+
const target_graph_1 = require("@lage-run/target-graph");
|
|
35
|
+
const logger_1 = __importStar(require("@lage-run/logger"));
|
|
36
|
+
function filterArgsForTasks(args) {
|
|
37
|
+
const optionsPosition = args.findIndex((arg) => arg.startsWith("-"));
|
|
38
|
+
return {
|
|
39
|
+
tasks: args.slice(0, optionsPosition === -1 ? undefined : optionsPosition),
|
|
40
|
+
taskArgs: optionsPosition === -1 ? [] : args.slice(optionsPosition),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function runAction(options, command) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const cwd = process.cwd();
|
|
46
|
+
const config = (0, getConfig_1.getConfig)(cwd);
|
|
47
|
+
const reporterInstances = [];
|
|
48
|
+
// Configure logger
|
|
49
|
+
const logger = (0, logger_1.default)();
|
|
50
|
+
const reporterOptions = Array.isArray(options.reporter) ? options.reporter : [options.reporter];
|
|
51
|
+
for (const reporter of reporterOptions) {
|
|
52
|
+
const reporterInstance = (0, createReporter_1.createReporter)({
|
|
53
|
+
verbose: options.verbose,
|
|
54
|
+
grouped: options.grouped,
|
|
55
|
+
logLevel: logger_1.LogLevel[options.logLevel],
|
|
56
|
+
reporter: reporter,
|
|
57
|
+
});
|
|
58
|
+
reporterInstances.push(reporterInstance);
|
|
59
|
+
logger.addReporter(reporterInstance);
|
|
60
|
+
}
|
|
61
|
+
// Build Target Graph
|
|
62
|
+
const root = (0, workspace_tools_1.getWorkspaceRoot)(process.cwd());
|
|
63
|
+
const packageInfos = (0, workspace_tools_1.getPackageInfos)(root);
|
|
64
|
+
const builder = new target_graph_1.TargetGraphBuilder(root, packageInfos);
|
|
65
|
+
const { tasks, taskArgs } = filterArgsForTasks(command.args);
|
|
66
|
+
const packages = (0, getFilteredPackages_1.getFilteredPackages)({
|
|
67
|
+
root,
|
|
68
|
+
logger,
|
|
69
|
+
packageInfos,
|
|
70
|
+
includeDependencies: options.dependencies,
|
|
71
|
+
includeDependents: options.dependents,
|
|
72
|
+
repoWideChanges: config.repoWideChanges,
|
|
73
|
+
since: options.since,
|
|
74
|
+
scope: options.scope,
|
|
75
|
+
});
|
|
76
|
+
for (const [id, definition] of Object.entries(config.pipeline)) {
|
|
77
|
+
if (Array.isArray(definition)) {
|
|
78
|
+
builder.addTargetConfig(id, {
|
|
79
|
+
cache: true,
|
|
80
|
+
dependsOn: definition,
|
|
81
|
+
options: {},
|
|
82
|
+
outputs: config.cacheOptions.outputGlob,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
builder.addTargetConfig(id, definition);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const targetGraph = builder.buildTargetGraph(tasks, packages);
|
|
90
|
+
// Create Cache Provider
|
|
91
|
+
const cacheProvider = new cache_1.RemoteFallbackCacheProvider({
|
|
92
|
+
root,
|
|
93
|
+
logger,
|
|
94
|
+
localCacheProvider: options.skipLocalCache === true
|
|
95
|
+
? undefined
|
|
96
|
+
: new cache_1.BackfillCacheProvider({
|
|
97
|
+
root,
|
|
98
|
+
cacheOptions: {
|
|
99
|
+
outputGlob: config.cacheOptions.outputGlob,
|
|
100
|
+
internalCacheFolder: config.cacheOptions.internalCacheFolder,
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
remoteCacheProvider: ((_a = config.cacheOptions) === null || _a === void 0 ? void 0 : _a.cacheStorageConfig)
|
|
104
|
+
? new cache_1.BackfillCacheProvider({ root, cacheOptions: config.cacheOptions })
|
|
105
|
+
: undefined,
|
|
106
|
+
writeRemoteCache: ((_b = config.cacheOptions) === null || _b === void 0 ? void 0 : _b.writeRemoteCache) === true || String(process.env.LAGE_WRITE_CACHE).toLowerCase() === "true",
|
|
107
|
+
});
|
|
108
|
+
const hasher = new cache_1.TargetHasher({
|
|
109
|
+
root,
|
|
110
|
+
environmentGlob: config.cacheOptions.environmentGlob,
|
|
111
|
+
cacheKey: config.cacheOptions.cacheKey,
|
|
112
|
+
});
|
|
113
|
+
// Run Tasks with Scheduler + NpmScriptRunner
|
|
114
|
+
const runner = new scheduler_1.NpmScriptRunner({
|
|
115
|
+
logger,
|
|
116
|
+
nodeOptions: options.nodeargs,
|
|
117
|
+
taskArgs,
|
|
118
|
+
npmCmd: (0, findNpmClient_1.findNpmClient)(config.npmClient),
|
|
119
|
+
});
|
|
120
|
+
const scheduler = new scheduler_1.SimpleScheduler({
|
|
121
|
+
logger,
|
|
122
|
+
concurrency: options.concurrency,
|
|
123
|
+
cacheProvider,
|
|
124
|
+
hasher,
|
|
125
|
+
continueOnError: options.continue,
|
|
126
|
+
shouldCache: options.cache,
|
|
127
|
+
shouldResetCache: options.resetCache,
|
|
128
|
+
runner,
|
|
129
|
+
});
|
|
130
|
+
const summary = await scheduler.run(root, targetGraph);
|
|
131
|
+
for (const reporterInstance of reporterInstances) {
|
|
132
|
+
reporterInstance.summarize(summary);
|
|
133
|
+
}
|
|
134
|
+
if (summary.results !== "success") {
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.runAction = runAction;
|
|
139
|
+
//# sourceMappingURL=runAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runAction.js","sourceRoot":"","sources":["../../../src/commands/run/runAction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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W,EAAE,OAAO,CAAC,WAAW;QAChC,aAAa;QACb,MAAM;QACN,eAAe,EAAE,OAAO,CAAC,QAAQ;QACjC,WAAW,EAAE,OAAO,CAAC,KAAK;QAC1B,gBAAgB,EAAE,OAAO,CAAC,UAAU;QACpC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEvD,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE;QAChD,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KACrC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QACjC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AA7GD,8BA6GC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfig = void 0;
|
|
4
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
6
|
+
function getConfig(cwd) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8
|
+
// Verify presence of git
|
|
9
|
+
const root = (0, workspace_tools_1.getWorkspaceRoot)(cwd);
|
|
10
|
+
if (!root) {
|
|
11
|
+
throw new Error("This must be called inside a codebase that is part of a JavaScript workspace.");
|
|
12
|
+
}
|
|
13
|
+
// Search for lage.config.js file
|
|
14
|
+
const ConfigModuleName = "lage";
|
|
15
|
+
const configResults = (0, cosmiconfig_1.cosmiconfigSync)(ConfigModuleName).search(root !== null && root !== void 0 ? root : cwd);
|
|
16
|
+
return {
|
|
17
|
+
cacheOptions: (_a = configResults === null || configResults === void 0 ? void 0 : configResults.config.cacheOptions) !== null && _a !== void 0 ? _a : {},
|
|
18
|
+
ignore: (_b = configResults === null || configResults === void 0 ? void 0 : configResults.config.ignore) !== null && _b !== void 0 ? _b : [],
|
|
19
|
+
npmClient: (_c = configResults === null || configResults === void 0 ? void 0 : configResults.config.npmClient) !== null && _c !== void 0 ? _c : "npm",
|
|
20
|
+
pipeline: (_d = configResults === null || configResults === void 0 ? void 0 : configResults.config.pipeline) !== null && _d !== void 0 ? _d : {},
|
|
21
|
+
priorities: (_e = configResults === null || configResults === void 0 ? void 0 : configResults.config.priorities) !== null && _e !== void 0 ? _e : [],
|
|
22
|
+
repoWideChanges: (_f = configResults === null || configResults === void 0 ? void 0 : configResults.config.repoWideChanges) !== null && _f !== void 0 ? _f : [
|
|
23
|
+
"lage.config.js",
|
|
24
|
+
"package-lock.json",
|
|
25
|
+
"yarn.lock",
|
|
26
|
+
"pnpm-lock.yaml",
|
|
27
|
+
"lerna.json",
|
|
28
|
+
"rush.json",
|
|
29
|
+
],
|
|
30
|
+
loggerOptions: (_g = configResults === null || configResults === void 0 ? void 0 : configResults.config.loggerOptions) !== null && _g !== void 0 ? _g : {},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.getConfig = getConfig;
|
|
34
|
+
//# sourceMappingURL=getConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfig.js","sourceRoot":"","sources":["../../src/config/getConfig.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAC9C,qDAAmD;AAGnD,SAAgB,SAAS,CAAC,GAAW;;IACnC,yBAAyB;IACzB,MAAM,IAAI,GAAG,IAAA,kCAAgB,EAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;KAClG;IAED,iCAAiC;IACjC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IAChC,MAAM,aAAa,GAAG,IAAA,6BAAe,EAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,GAAG,CAAC,CAAC;IAC5E,OAAO;QACL,YAAY,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,YAAY,mCAAI,EAAE;QACtD,MAAM,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,MAAM,mCAAI,EAAE;QAC1C,SAAS,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,SAAS,mCAAI,KAAK;QACnD,QAAQ,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,QAAQ,mCAAI,EAAE;QAC9C,UAAU,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,UAAU,mCAAI,EAAE;QAClD,eAAe,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,eAAe,mCAAI;YACxD,gBAAgB;YAChB,mBAAmB;YACnB,WAAW;YACX,gBAAgB;YAChB,YAAY;YACZ,WAAW;SACZ;QACD,aAAa,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAC,aAAa,mCAAI,EAAE;KACzD,CAAC;AACJ,CAAC;AA1BD,8BA0BC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LogLevel } from "@lage-run/logger";
|
|
2
|
+
import { JsonReporter, AdoReporter, NpmLogReporter } from "@lage-run/reporters";
|
|
3
|
+
export declare function createReporter({ reporter, grouped, verbose, logLevel, }: {
|
|
4
|
+
reporter: string;
|
|
5
|
+
grouped?: boolean;
|
|
6
|
+
verbose?: boolean;
|
|
7
|
+
logLevel?: LogLevel;
|
|
8
|
+
}): JsonReporter | AdoReporter | NpmLogReporter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReporter = void 0;
|
|
4
|
+
const logger_1 = require("@lage-run/logger");
|
|
5
|
+
const reporters_1 = require("@lage-run/reporters");
|
|
6
|
+
function createReporter({ reporter = "npmLog", grouped = false, verbose = false, logLevel = logger_1.LogLevel.info, }) {
|
|
7
|
+
switch (reporter) {
|
|
8
|
+
case "json":
|
|
9
|
+
return new reporters_1.JsonReporter({ logLevel });
|
|
10
|
+
case "azureDevops":
|
|
11
|
+
case "adoLog":
|
|
12
|
+
return new reporters_1.AdoReporter({ grouped, logLevel: verbose ? logger_1.LogLevel.verbose : logLevel });
|
|
13
|
+
default:
|
|
14
|
+
return new reporters_1.NpmLogReporter({ grouped, logLevel: verbose ? logger_1.LogLevel.verbose : logLevel });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.createReporter = createReporter;
|
|
18
|
+
//# sourceMappingURL=createReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createReporter.js","sourceRoot":"","sources":["../src/createReporter.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,mDAAgF;AAEhF,SAAgB,cAAc,CAAC,EAC7B,QAAQ,GAAG,QAAQ,EACnB,OAAO,GAAG,KAAK,EACf,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,iBAAQ,CAAC,IAAI,GAMzB;IACC,QAAQ,QAAQ,EAAE;QAChB,KAAK,MAAM;YACT,OAAO,IAAI,wBAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxC,KAAK,aAAa,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,IAAI,uBAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvF;YACE,OAAO,IAAI,0BAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;KAC3F;AACH,CAAC;AApBD,wCAoBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PackageInfos } from "workspace-tools";
|
|
2
|
+
import { Logger } from "@lage-run/logger";
|
|
3
|
+
export declare function getFilteredPackages(options: {
|
|
4
|
+
root: string;
|
|
5
|
+
packageInfos: PackageInfos;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
scope: string[] | undefined;
|
|
8
|
+
since: string | undefined;
|
|
9
|
+
repoWideChanges: string[];
|
|
10
|
+
includeDependents: boolean;
|
|
11
|
+
includeDependencies: boolean;
|
|
12
|
+
}): string[];
|
|
13
|
+
export declare function filterPackages(options: {
|
|
14
|
+
logger: Logger;
|
|
15
|
+
packageInfos: PackageInfos;
|
|
16
|
+
includeDependents: boolean;
|
|
17
|
+
includeDependencies: boolean;
|
|
18
|
+
scopedPackages: string[] | undefined;
|
|
19
|
+
changedPackages: string[] | undefined;
|
|
20
|
+
}): string[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.filterPackages = exports.getFilteredPackages = void 0;
|
|
27
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
28
|
+
const fg = __importStar(require("fast-glob"));
|
|
29
|
+
function getFilteredPackages(options) {
|
|
30
|
+
const { scope, since, repoWideChanges, includeDependents, includeDependencies, logger, packageInfos, root } = options;
|
|
31
|
+
// If scoped is defined, get scoped packages
|
|
32
|
+
const hasScopes = Array.isArray(scope) && scope.length > 0;
|
|
33
|
+
let scopedPackages = undefined;
|
|
34
|
+
if (hasScopes) {
|
|
35
|
+
scopedPackages = (0, workspace_tools_1.getScopedPackages)(scope, packageInfos);
|
|
36
|
+
}
|
|
37
|
+
const hasSince = typeof since !== "undefined";
|
|
38
|
+
let changedPackages = undefined;
|
|
39
|
+
// Be specific with the changed packages only if no repo-wide changes occurred
|
|
40
|
+
if (hasSince && !hasRepoChanged(since, root, repoWideChanges, logger)) {
|
|
41
|
+
try {
|
|
42
|
+
changedPackages = (0, workspace_tools_1.getChangedPackages)(root, since);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
logger.warn(`An error in the git command has caused this scope run to include every package\n${e}`);
|
|
46
|
+
// if getChangedPackages throws, we will assume all have changed (using changedPackage = undefined)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return filterPackages({
|
|
50
|
+
logger,
|
|
51
|
+
packageInfos,
|
|
52
|
+
scopedPackages,
|
|
53
|
+
changedPackages,
|
|
54
|
+
includeDependencies,
|
|
55
|
+
includeDependents,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.getFilteredPackages = getFilteredPackages;
|
|
59
|
+
function hasRepoChanged(since, root, environmentGlob, logger) {
|
|
60
|
+
try {
|
|
61
|
+
const changedFiles = (0, workspace_tools_1.getBranchChanges)(since, root);
|
|
62
|
+
const envFiles = fg.sync(environmentGlob, { cwd: root });
|
|
63
|
+
let repoWideChanged = false;
|
|
64
|
+
if (changedFiles) {
|
|
65
|
+
for (const change of changedFiles) {
|
|
66
|
+
if (envFiles.includes(change)) {
|
|
67
|
+
repoWideChanged = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return repoWideChanged;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// if this fails, let's assume repo has changed
|
|
76
|
+
logger.warn(`An error in the git command has caused this to consider the repo has changed\n${e}`);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function filterPackages(options) {
|
|
81
|
+
const { scopedPackages, changedPackages, packageInfos, includeDependents, includeDependencies, logger } = options;
|
|
82
|
+
let filtered = [];
|
|
83
|
+
// If scope is defined, use the transitive providers of the since packages up to the scope
|
|
84
|
+
if (typeof scopedPackages !== "undefined" && typeof changedPackages !== "undefined") {
|
|
85
|
+
// If both scoped and since are specified, we have to merge two lists:
|
|
86
|
+
// 1. changed packages that ARE themselves the scoped packages
|
|
87
|
+
// 2. changed package consumers (package dependents) that are within the scoped subgraph
|
|
88
|
+
filtered = changedPackages
|
|
89
|
+
.filter((pkg) => scopedPackages.includes(pkg))
|
|
90
|
+
.concat((0, workspace_tools_1.getTransitiveDependents)(changedPackages, packageInfos, scopedPackages));
|
|
91
|
+
logger.verbose(`filterPackages changed within scope: ${filtered.join(",")}`);
|
|
92
|
+
}
|
|
93
|
+
else if (typeof changedPackages !== "undefined") {
|
|
94
|
+
filtered = [...changedPackages];
|
|
95
|
+
logger.verbose(`filterPackages changed: ${changedPackages.join(",")}`);
|
|
96
|
+
}
|
|
97
|
+
else if (typeof scopedPackages !== "undefined") {
|
|
98
|
+
filtered = [...scopedPackages];
|
|
99
|
+
logger.verbose(`filterPackages scope: ${scopedPackages.join(",")}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
filtered = Object.keys(packageInfos);
|
|
103
|
+
}
|
|
104
|
+
// adds dependents (consumers) of all filtered package thus far
|
|
105
|
+
if (includeDependents) {
|
|
106
|
+
logger.verbose(`filterPackages running with dependents`);
|
|
107
|
+
filtered = filtered.concat((0, workspace_tools_1.getTransitiveDependents)(filtered, packageInfos));
|
|
108
|
+
}
|
|
109
|
+
// adds dependencies of all filtered package thus far
|
|
110
|
+
if (includeDependencies) {
|
|
111
|
+
filtered = filtered.concat((0, workspace_tools_1.getTransitiveDependencies)(filtered, packageInfos));
|
|
112
|
+
}
|
|
113
|
+
const unique = new Set(filtered);
|
|
114
|
+
return [...unique];
|
|
115
|
+
}
|
|
116
|
+
exports.filterPackages = filterPackages;
|
|
117
|
+
//# sourceMappingURL=getFilteredPackages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFilteredPackages.js","sourceRoot":"","sources":["../../src/filter/getFilteredPackages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAOyB;AACzB,8CAAgC;AAGhC,SAAgB,mBAAmB,CAAC,OASnC;IACC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtH,4CAA4C;IAC5C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3D,IAAI,cAAc,GAAyB,SAAS,CAAC;IACrD,IAAI,SAAS,EAAE;QACb,cAAc,GAAG,IAAA,mCAAiB,EAAC,KAAM,EAAE,YAAY,CAAC,CAAC;KAC1D;IAED,MAAM,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AqD;IACrD,IAAI,mBAAmB,EAAE;QACvB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAA,2CAAyB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/E;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACrB,CAAC;AA9CD,wCA8CC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ConfigOptions } from "./types/ConfigOptions";
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheOptions.js","sourceRoot":"","sources":["../../src/types/CacheOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CacheOptions } from "./CacheOptions";
|
|
2
|
+
import { Priority } from "./Priority";
|
|
3
|
+
import { PipelineDefinition } from "./PipelineDefinition";
|
|
4
|
+
import { LoggerOptions } from "./LoggerOptions";
|
|
5
|
+
export declare type NpmClient = "npm" | "yarn" | "pnpm";
|
|
6
|
+
export interface ConfigOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Defines the task pipeline, prefix with "^" character to denote a direct topological dependency,
|
|
9
|
+
* prefix with ^^ to denote a transitive topological dependency.
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* {
|
|
15
|
+
* build: ["^build"],
|
|
16
|
+
* test: ["build"],
|
|
17
|
+
* lint: []
|
|
18
|
+
* bundle: ["^^transpile"],
|
|
19
|
+
* transpile: [],
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
pipeline: PipelineDefinition;
|
|
24
|
+
/** Backfill cache options */
|
|
25
|
+
cacheOptions: CacheOptions;
|
|
26
|
+
/** Which files to ignore when calculating scopes with --since */
|
|
27
|
+
ignore: string[];
|
|
28
|
+
/** disables --since flag when any of this list of files changed */
|
|
29
|
+
repoWideChanges: string[];
|
|
30
|
+
/** Which NPM Client to use when running npm lifecycle scripts */
|
|
31
|
+
npmClient: NpmClient;
|
|
32
|
+
/** Optional priority to set on tasks in a package to make the scheduler give priority to tasks on the critical path for high priority tasks */
|
|
33
|
+
priorities: Priority[];
|
|
34
|
+
/**
|
|
35
|
+
* Options that will be sent to all log reporters.
|
|
36
|
+
*/
|
|
37
|
+
loggerOptions: LoggerOptions;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigOptions.js","sourceRoot":"","sources":["../../src/types/ConfigOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LogLevel } from "@lage-run/logger";
|
|
2
|
+
export interface LoggerOptions {
|
|
3
|
+
disp?: {
|
|
4
|
+
[level: string]: string;
|
|
5
|
+
};
|
|
6
|
+
style?: {
|
|
7
|
+
[level: string]: {
|
|
8
|
+
fg?: string;
|
|
9
|
+
bg?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
levels?: {
|
|
13
|
+
[level: string]: LogLevel;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerOptions.js","sourceRoot":"","sources":["../../src/types/LoggerOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TargetConfig } from "@lage-run/target-graph";
|
|
2
|
+
import { ConfigOptions } from "./ConfigOptions";
|
|
3
|
+
export interface FactoryArgs {
|
|
4
|
+
cwd: string;
|
|
5
|
+
config: ConfigOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface TargetConfigFactory {
|
|
8
|
+
(args: FactoryArgs): TargetConfig | TargetConfig[];
|
|
9
|
+
}
|
|
10
|
+
export interface PipelineDefinition {
|
|
11
|
+
[task: string]: string[] | TargetConfig;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PipelineDefinition.js","sourceRoot":"","sources":["../../src/types/PipelineDefinition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Priority {
|
|
2
|
+
/** package name, as in package.json */
|
|
3
|
+
package?: string;
|
|
4
|
+
/** task name, as listed in the `scripts` section of package.json */
|
|
5
|
+
task: string;
|
|
6
|
+
/** priority, the higher the more priority; undefined priority means lowest priority*/
|
|
7
|
+
priority: number;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Priority.js","sourceRoot":"","sources":["../../src/types/Priority.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findNpmClient(npmClient: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findNpmClient = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
function findNpmClient(npmClient) {
|
|
10
|
+
const found = findInPath(npmClient);
|
|
11
|
+
if (!found) {
|
|
12
|
+
throw new Error(`npm client not found: ${npmClient}`);
|
|
13
|
+
}
|
|
14
|
+
return found;
|
|
15
|
+
}
|
|
16
|
+
exports.findNpmClient = findNpmClient;
|
|
17
|
+
function findInPath(target) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const envPath = (_a = process.env.PATH) !== null && _a !== void 0 ? _a : "";
|
|
20
|
+
const pathExt = (_b = process.env.PATHEXT) !== null && _b !== void 0 ? _b : "";
|
|
21
|
+
for (const search of envPath.split(path_1.default.delimiter)) {
|
|
22
|
+
const found = pathExt
|
|
23
|
+
.split(path_1.default.delimiter)
|
|
24
|
+
.map((ext) => path_1.default.join(search, `${target}${ext}`))
|
|
25
|
+
.find((p) => fs_1.default.existsSync(p));
|
|
26
|
+
if (found) {
|
|
27
|
+
return found;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=findNpmClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findNpmClient.js","sourceRoot":"","sources":["../../src/workspace/findNpmClient.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAEpC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;KACvD;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AARD,sCAQC;AAED,SAAS,UAAU,CAAC,MAAc;;IAChC,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,IAAI,mCAAI,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,OAAO,mCAAI,EAAE,CAAC;IAE1C,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,cAAI,CAAC,SAAS,CAAC,EAAE;QAClD,MAAM,KAAK,GAAG,OAAO;aAClB,KAAK,CAAC,cAAI,CAAC,SAAS,CAAC;aACrB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;aAClD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC;SACd;KACF;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lage-run/cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Command Line Interface for Lage",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/microsoft/lage"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"lage": "./bin/lage"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"types": "lib/index.d.ts",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"start": "tsc -w --preserveWatchOutput",
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@lage-run/logger": "^1.1.2",
|
|
21
|
+
"@lage-run/scheduler": "^0.1.3",
|
|
22
|
+
"@lage-run/target-graph": "^0.2.0",
|
|
23
|
+
"@lage-run/cache": "^0.1.3",
|
|
24
|
+
"@lage-run/reporters": "^0.1.2",
|
|
25
|
+
"commander": "^9.4.0",
|
|
26
|
+
"workspace-tools": "^0.23.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jest": "^27.0.1",
|
|
30
|
+
"@types/node": "^14.0.0",
|
|
31
|
+
"jest": "^27.2.0",
|
|
32
|
+
"memory-streams": "^0.1.3",
|
|
33
|
+
"ts-jest": "^27.0.5",
|
|
34
|
+
"typescript": "^4.4.4"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ts-node": {
|
|
3
|
+
"transpileOnly": true
|
|
4
|
+
},
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"target": "ES2017",
|
|
7
|
+
"module": "CommonJS",
|
|
8
|
+
"moduleResolution": "Node",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"lib": ["ES2017"],
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"outDir": "./lib",
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noImplicitAny": false,
|
|
15
|
+
"allowSyntheticDefaultImports": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"noUnusedLocals": false,
|
|
20
|
+
"sourceMap": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/cli.ts", "src/index.ts"]
|
|
23
|
+
}
|