@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 ADDED
File without changes
@@ -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 rushLib = require('@microsoft/rush-lib');
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 rush = resolveWorkspace();
52
- if (rush) isWorkspace = true;
52
+ const workspaceConfig = resolveWorkspace();
53
+ if (workspaceConfig) isWorkspace = true;
53
54
 
54
- const workspace = rush
55
+ const workspace = workspaceConfig
55
56
  ? {
56
- config: rush,
57
- root: rush.rushJsonFolder,
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 project's Rush workspace configuration
173
+ * Resolve the pnpm workspace configuration using `pnpm ls`
170
174
  *
171
- * @returns {rushLib.RushConfiguration | null} - The Rush configuration or null if not found
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 rushConfiguration = rushLib.RushConfiguration.loadFromDefaultLocation(
176
- {
177
- startingFolder: process.cwd(),
178
- }
179
- );
180
- return rushConfiguration;
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
- // No rush config, ignore error
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 rush = resolveWorkspace();
217
+ const workspace = resolveWorkspace();
193
218
  /** @type {{ [key: string]: ReturnType<typeof resolveProject> }} */
194
219
  let localPackages = {};
195
- if (rush) {
196
- const rushProjects = rush.projects;
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.8",
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
  },