@digigov/cli 2.0.8 → 2.0.9-platform-196.17-02-26-12-34
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/LICENSE +0 -0
- package/lib/project-utils.cjs +44 -20
- package/package.json +1 -2
package/LICENSE
ADDED
|
File without changes
|
package/lib/project-utils.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const merge = require('deepmerge');
|
|
4
|
-
const
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
const assert = require('assert');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Resolve the project configuration from the nearest package.json
|
|
@@ -48,13 +49,13 @@ function resolveProject(dir) {
|
|
|
48
49
|
isLib = true;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
52
|
+
const workspaceConfig = resolveWorkspace();
|
|
53
|
+
if (workspaceConfig) isWorkspace = true;
|
|
53
54
|
|
|
54
|
-
const workspace =
|
|
55
|
+
const workspace = workspaceConfig
|
|
55
56
|
? {
|
|
56
|
-
config:
|
|
57
|
-
root:
|
|
57
|
+
config: workspaceConfig,
|
|
58
|
+
root: workspaceConfig.root,
|
|
58
59
|
}
|
|
59
60
|
: {};
|
|
60
61
|
|
|
@@ -165,23 +166,47 @@ function makeConfig(file, cfg = {}) {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
/** @type {{ root: string, projects: { packageName: string, projectFolder: string }[] } | null | undefined} */
|
|
170
|
+
let _workspaceCache;
|
|
171
|
+
|
|
168
172
|
/**
|
|
169
|
-
* Resolve the
|
|
173
|
+
* Resolve the pnpm workspace configuration using `pnpm ls`
|
|
170
174
|
*
|
|
171
|
-
* @returns {
|
|
175
|
+
* @returns {{ root: string, projects: { packageName: string, projectFolder: string }[] } | null}
|
|
172
176
|
*/
|
|
173
177
|
function resolveWorkspace() {
|
|
178
|
+
if (_workspaceCache !== undefined) return _workspaceCache;
|
|
179
|
+
|
|
174
180
|
try {
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
const output = execSync('pnpm ls -r --json --depth -1', {
|
|
182
|
+
encoding: 'utf-8',
|
|
183
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
184
|
+
});
|
|
185
|
+
/** @type {{ name: string, version: string, private: boolean, path: string }[]} */
|
|
186
|
+
const packages = JSON.parse(output);
|
|
187
|
+
|
|
188
|
+
if (!packages.length) {
|
|
189
|
+
_workspaceCache = null;
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const root = packages.find((pkg) => pkg.name === 'digigov-sdk')?.path;
|
|
194
|
+
assert(!!root, 'Expected to find a package named "digigov-sdk" in the workspace');
|
|
195
|
+
|
|
196
|
+
// First entry is the workspace root
|
|
197
|
+
const projects = packages
|
|
198
|
+
.filter((pkg) => pkg.name !== 'digigov-sdk')
|
|
199
|
+
.map((pkg) => ({
|
|
200
|
+
packageName: pkg.name,
|
|
201
|
+
projectFolder: pkg.path,
|
|
202
|
+
}));
|
|
203
|
+
|
|
204
|
+
_workspaceCache = { root, projects };
|
|
205
|
+
return _workspaceCache;
|
|
181
206
|
} catch {
|
|
182
|
-
|
|
207
|
+
_workspaceCache = null;
|
|
208
|
+
return null;
|
|
183
209
|
}
|
|
184
|
-
return null;
|
|
185
210
|
}
|
|
186
211
|
|
|
187
212
|
/**
|
|
@@ -189,12 +214,11 @@ function resolveWorkspace() {
|
|
|
189
214
|
* @returns {{ [key: string]: ReturnType<typeof resolveProject> }} - The local packages
|
|
190
215
|
*/
|
|
191
216
|
function resolveLocalPackages(dependencies) {
|
|
192
|
-
const
|
|
217
|
+
const workspace = resolveWorkspace();
|
|
193
218
|
/** @type {{ [key: string]: ReturnType<typeof resolveProject> }} */
|
|
194
219
|
let localPackages = {};
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
for (const project of rushProjects) {
|
|
220
|
+
if (workspace) {
|
|
221
|
+
for (const project of workspace.projects) {
|
|
198
222
|
if (dependencies.includes(project.packageName)) {
|
|
199
223
|
localPackages[project.packageName] = resolveProject(
|
|
200
224
|
project.projectFolder
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli",
|
|
3
3
|
"description": "CLI for Digigov apps and libs with plugin support",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.9-platform-196.17-02-26-12-34",
|
|
5
5
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"fs-extra": "11.2.0",
|
|
12
12
|
"deepmerge": "4.3.1",
|
|
13
13
|
"execa": "8.0.1",
|
|
14
|
-
"@microsoft/rush-lib": "5.151.0",
|
|
15
14
|
"commander": "12.1.0",
|
|
16
15
|
"chalk": "4.1.0"
|
|
17
16
|
},
|