@carbon/cli 10.29.0 → 10.32.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/package.json +5 -5
- package/src/workspace.js +67 -17
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/cli",
|
|
3
3
|
"description": "Task automation for working with the Carbon Design System",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.32.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"carbon-cli": "./bin/carbon-cli.js"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@babel/core": "^7.
|
|
26
|
+
"@babel/core": "^7.16.7",
|
|
27
27
|
"@carbon/cli-reporter": "^10.5.0",
|
|
28
28
|
"@octokit/plugin-retry": "^3.0.7",
|
|
29
29
|
"@octokit/plugin-throttling": "^2.6.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"clipboardy": "^2.1.0",
|
|
38
38
|
"enquirer": "^2.3.6",
|
|
39
39
|
"fast-glob": "^3.2.7",
|
|
40
|
-
"fs-extra": "^
|
|
40
|
+
"fs-extra": "^10.0.0",
|
|
41
41
|
"inquirer": "^6.4.1",
|
|
42
42
|
"klaw-sync": "^6.0.0",
|
|
43
43
|
"lodash.template": "^4.5.0",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"remark": "^10.0.1",
|
|
49
49
|
"replace-in-file": "^6.1.0",
|
|
50
50
|
"rollup": "^2.46.0",
|
|
51
|
-
"sass": "^1.
|
|
51
|
+
"sass": "^1.43.3",
|
|
52
52
|
"sassdoc": "^2.7.3",
|
|
53
53
|
"yargs": "^17.0.1"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ac4b4bf03cf93cb8463916231619fbfdc72f0be5"
|
|
56
56
|
}
|
package/src/workspace.js
CHANGED
|
@@ -11,23 +11,26 @@ const execa = require('execa');
|
|
|
11
11
|
const fs = require('fs-extra');
|
|
12
12
|
const glob = require('fast-glob');
|
|
13
13
|
const path = require('path');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const WORKSPACE_ROOT =
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
|
|
15
|
+
const { root: ROOT_DIR } = path.parse(__dirname);
|
|
16
|
+
const WORKSPACE_ROOT = getProjectRoot(__dirname);
|
|
17
|
+
const packageJson = fs.readJsonSync(path.join(WORKSPACE_ROOT, 'package.json'));
|
|
18
|
+
const packagePaths = Array.isArray(packageJson.workspaces)
|
|
19
|
+
? glob
|
|
20
|
+
.sync(packageJson.workspaces.map((pattern) => `${pattern}/package.json`))
|
|
21
|
+
.map((match) => {
|
|
22
|
+
const packageJsonPath = path.join(WORKSPACE_ROOT, match);
|
|
23
|
+
return {
|
|
24
|
+
packageJsonPath,
|
|
25
|
+
packageJson: fs.readJsonSync(packageJsonPath),
|
|
26
|
+
packagePath: path.dirname(packageJsonPath),
|
|
27
|
+
packageFolder: path.relative(
|
|
28
|
+
WORKSPACE_ROOT,
|
|
29
|
+
path.dirname(packageJsonPath)
|
|
30
|
+
),
|
|
31
|
+
};
|
|
32
|
+
})
|
|
33
|
+
: [];
|
|
31
34
|
|
|
32
35
|
const env = {
|
|
33
36
|
root: {
|
|
@@ -54,6 +57,53 @@ async function getPackages() {
|
|
|
54
57
|
return JSON.parse(lernaListOutput).filter((pkg) => !pkg.private);
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Returns the root directory of a project, either as a workspace root with a
|
|
62
|
+
* collection of packages or a single project with a `package.json`
|
|
63
|
+
* @param {string} directory
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
function getProjectRoot(directory) {
|
|
67
|
+
const packageJsonPaths = ancestors(directory).filter((directory) => {
|
|
68
|
+
return fs.existsSync(path.join(directory, 'package.json'));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const rootDirectory =
|
|
72
|
+
packageJsonPaths.length > 0
|
|
73
|
+
? packageJsonPaths[packageJsonPaths.length - 1]
|
|
74
|
+
: null;
|
|
75
|
+
|
|
76
|
+
if (!rootDirectory) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Unable to find a \`package.json\` file from directory: ${directory}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return rootDirectory;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns an array of the the directory and its ancestors
|
|
87
|
+
* @param {string} directory
|
|
88
|
+
* @returns {Array<string>}
|
|
89
|
+
*/
|
|
90
|
+
function ancestors(directory) {
|
|
91
|
+
const result = [directory];
|
|
92
|
+
let current = directory;
|
|
93
|
+
|
|
94
|
+
while (current !== '') {
|
|
95
|
+
result.push(current);
|
|
96
|
+
|
|
97
|
+
if (current !== ROOT_DIR) {
|
|
98
|
+
current = path.dirname(current);
|
|
99
|
+
} else {
|
|
100
|
+
current = '';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
57
107
|
module.exports = {
|
|
58
108
|
workspace,
|
|
59
109
|
getPackages,
|