@lage-run/cli 0.14.0 → 0.15.0
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 +28 -1
- package/CHANGELOG.md +12 -2
- package/lib/cli.js +2 -0
- package/lib/commands/init/action.d.ts +1 -0
- package/lib/commands/init/action.js +119 -0
- package/lib/commands/init/index.d.ts +3 -0
- package/lib/commands/init/index.js +13 -0
- package/package.json +11 -10
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,34 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 26 Apr 2023 04:56:07 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.15.0",
|
|
7
|
+
"version": "0.15.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8",
|
|
14
|
+
"comment": "Add back the init command"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@lage-run/cli",
|
|
19
|
+
"comment": "Bump @lage-run/config to v0.2.0",
|
|
20
|
+
"commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@lage-run/cli",
|
|
25
|
+
"comment": "Bump @lage-run/scheduler to v0.11.4",
|
|
26
|
+
"commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"date": "Tue, 25 Apr 2023 02:51:19 GMT",
|
|
6
33
|
"tag": "@lage-run/cli_v0.14.0",
|
|
7
34
|
"version": "0.14.0",
|
|
8
35
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 26 Apr 2023 04:56:07 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.15.0
|
|
8
|
+
|
|
9
|
+
Wed, 26 Apr 2023 04:56:07 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Add back the init command (elcraig@microsoft.com)
|
|
14
|
+
- Bump @lage-run/config to v0.2.0
|
|
15
|
+
- Bump @lage-run/scheduler to v0.11.4
|
|
16
|
+
|
|
7
17
|
## 0.14.0
|
|
8
18
|
|
|
9
|
-
Tue, 25 Apr 2023 02:
|
|
19
|
+
Tue, 25 Apr 2023 02:51:19 GMT
|
|
10
20
|
|
|
11
21
|
### Minor changes
|
|
12
22
|
|
package/lib/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const _indexJs = require("./commands/run/index.js");
|
|
|
7
7
|
const _indexJs1 = require("./commands/cache/index.js");
|
|
8
8
|
const _errorsJs = require("./types/errors.js");
|
|
9
9
|
const _indexJs2 = require("./commands/affected/index.js");
|
|
10
|
+
const _indexJs3 = require("./commands/init/index.js");
|
|
10
11
|
async function main() {
|
|
11
12
|
const program = new _commander.Command();
|
|
12
13
|
program.addCommand(_indexJs.runCommand, {
|
|
@@ -14,6 +15,7 @@ async function main() {
|
|
|
14
15
|
});
|
|
15
16
|
program.addCommand(_indexJs1.cacheCommand);
|
|
16
17
|
program.addCommand(_indexJs2.affectedCommand);
|
|
18
|
+
program.addCommand(_indexJs3.initCommand);
|
|
17
19
|
await program.parseAsync(process.argv);
|
|
18
20
|
}
|
|
19
21
|
main().catch((err)=>{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initAction(): Promise<void>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* eslint-disable no-console -- logger doesn't work in this context */ "use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>initAction
|
|
8
|
+
});
|
|
9
|
+
const _config = require("@lage-run/config");
|
|
10
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
11
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
12
|
+
const _execa = /*#__PURE__*/ _interopRequireDefault(require("execa"));
|
|
13
|
+
function _interopRequireDefault(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var _packageJson, _packageJson1;
|
|
19
|
+
async function initAction() {
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
const config = await (0, _config.readConfigFile)(cwd);
|
|
22
|
+
if (config) {
|
|
23
|
+
console.error("lage is already initialized in this workspace");
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.info("Installing lage and creating a default configuration file");
|
|
28
|
+
let workspaceManager = "yarn";
|
|
29
|
+
try {
|
|
30
|
+
workspaceManager = whichWorkspaceManager(cwd);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error("lage requires you to be using a workspace - make sure you are using yarn workspaces, npm workspaces, pnpm workspaces, or rush");
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const pipeline = {
|
|
37
|
+
build: [
|
|
38
|
+
"^build"
|
|
39
|
+
],
|
|
40
|
+
test: [
|
|
41
|
+
"build"
|
|
42
|
+
],
|
|
43
|
+
lint: []
|
|
44
|
+
};
|
|
45
|
+
const lageConfig = {
|
|
46
|
+
pipeline,
|
|
47
|
+
npmClient: workspaceManager === "yarn" ? "yarn" : "npm"
|
|
48
|
+
};
|
|
49
|
+
const lageConfigFile = _path.default.join(cwd, "lage.config.js");
|
|
50
|
+
_fs.default.writeFileSync(lageConfigFile, "module.exports = " + JSON.stringify(lageConfig, null, 2) + ";");
|
|
51
|
+
installLage(cwd, workspaceManager, pipeline);
|
|
52
|
+
console.info(`Lage is initialized! You can now run: ${getBuildCommand(workspaceManager)}`);
|
|
53
|
+
}
|
|
54
|
+
function getBuildCommand(workspaceManager) {
|
|
55
|
+
switch(workspaceManager){
|
|
56
|
+
case "yarn":
|
|
57
|
+
return "yarn lage build";
|
|
58
|
+
case "pnpm":
|
|
59
|
+
return "pnpm run lage build";
|
|
60
|
+
case "rush":
|
|
61
|
+
case "npm":
|
|
62
|
+
return "npm run lage build";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function whichWorkspaceManager(cwd) {
|
|
66
|
+
const packageJson = readPackageJson(cwd);
|
|
67
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "rush.json"))) {
|
|
68
|
+
return "rush";
|
|
69
|
+
}
|
|
70
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "yarn.lock")) && packageJson.workspaces) {
|
|
71
|
+
return "yarn";
|
|
72
|
+
}
|
|
73
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "pnpm-workspace.yaml"))) {
|
|
74
|
+
return "pnpm";
|
|
75
|
+
}
|
|
76
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "package-lock.json")) && packageJson.workspaces) {
|
|
77
|
+
return "npm";
|
|
78
|
+
}
|
|
79
|
+
throw new Error("not a workspace");
|
|
80
|
+
}
|
|
81
|
+
async function installLage(cwd, workspaceManager, pipeline) {
|
|
82
|
+
const lageVersion = getLageVersion();
|
|
83
|
+
const packageJson = readPackageJson(cwd);
|
|
84
|
+
(_packageJson = packageJson).scripts ?? (_packageJson.scripts = {});
|
|
85
|
+
for (const script of Object.keys(pipeline)){
|
|
86
|
+
packageJson.scripts[script] = `lage ${script}`;
|
|
87
|
+
}
|
|
88
|
+
if (workspaceManager === "rush") {
|
|
89
|
+
packageJson.scripts.lage = `node common/scripts/install-run.js lage@${lageVersion} lage`;
|
|
90
|
+
writePackageJson(cwd, packageJson);
|
|
91
|
+
} else {
|
|
92
|
+
packageJson.scripts.lage = "lage";
|
|
93
|
+
(_packageJson1 = packageJson).devDependencies ?? (_packageJson1.devDependencies = {});
|
|
94
|
+
packageJson.devDependencies.lage = lageVersion;
|
|
95
|
+
writePackageJson(cwd, packageJson);
|
|
96
|
+
await (0, _execa.default)(workspaceManager, [
|
|
97
|
+
"install"
|
|
98
|
+
], {
|
|
99
|
+
stdio: "inherit"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function getLageVersion() {
|
|
104
|
+
const lagePackageJsonFile = require.resolve("../../package.json", {
|
|
105
|
+
paths: [
|
|
106
|
+
__dirname
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
const lagePackageJson = JSON.parse(_fs.default.readFileSync(lagePackageJsonFile, "utf-8"));
|
|
110
|
+
return lagePackageJson.version;
|
|
111
|
+
}
|
|
112
|
+
function writePackageJson(cwd, packageJson) {
|
|
113
|
+
const packageJsonFile = _path.default.join(cwd, "package.json");
|
|
114
|
+
_fs.default.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
|
115
|
+
}
|
|
116
|
+
function readPackageJson(cwd) {
|
|
117
|
+
const packageJsonFile = _path.default.join(cwd, "package.json");
|
|
118
|
+
return JSON.parse(_fs.default.readFileSync(packageJsonFile, "utf-8"));
|
|
119
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initCommand", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>initCommand
|
|
8
|
+
});
|
|
9
|
+
const _commander = require("commander");
|
|
10
|
+
const _addFilterOptionsJs = require("../addFilterOptions.js");
|
|
11
|
+
const _actionJs = require("./action.js");
|
|
12
|
+
const initCommand = new _commander.Command("init");
|
|
13
|
+
(0, _addFilterOptionsJs.addFilterOptions)(initCommand).description("Install lage in a workspace and create a config file").action(_actionJs.initAction);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,22 +20,23 @@
|
|
|
20
20
|
"lint": "monorepo-scripts lint"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lage-run/
|
|
23
|
+
"@lage-run/cache": "^0.5.4",
|
|
24
|
+
"@lage-run/config": "^0.2.0",
|
|
24
25
|
"@lage-run/find-npm-client": "^0.1.4",
|
|
25
26
|
"@lage-run/logger": "^1.3.0",
|
|
26
|
-
"@lage-run/
|
|
27
|
+
"@lage-run/reporters": "^1.2.0",
|
|
28
|
+
"@lage-run/scheduler": "^0.11.4",
|
|
27
29
|
"@lage-run/scheduler-types": "^0.3.8",
|
|
28
30
|
"@lage-run/target-graph": "^0.8.4",
|
|
29
|
-
"@lage-run/cache": "^0.5.4",
|
|
30
|
-
"@lage-run/reporters": "^1.2.0",
|
|
31
|
-
"commander": "^9.4.0",
|
|
32
|
-
"workspace-tools": "^0.34.0",
|
|
33
31
|
"chokidar": "3.5.3",
|
|
34
|
-
"
|
|
32
|
+
"commander": "^9.4.0",
|
|
33
|
+
"execa": "5.1.1",
|
|
34
|
+
"fast-glob": "^3.2.11",
|
|
35
|
+
"workspace-tools": "^0.34.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"monorepo-
|
|
38
|
-
"
|
|
38
|
+
"@lage-run/monorepo-fixture": "*",
|
|
39
|
+
"monorepo-scripts": "*"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|