@sitecore-jss/sitecore-jss-dev-tools 22.2.0-canary.8 → 22.2.0-canary.80

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.
@@ -1,32 +1,36 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getMetadata = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
4
+ const child_process_1 = require("child_process");
5
+ const trackedScopes = ['@sitecore', '@sitecore-cloudsdk', '@sitecore-feaas', '@sitecore-jss'];
9
6
  /**
10
7
  * Get application metadata
11
8
  */
12
9
  function getMetadata() {
13
10
  const metadata = { packages: {} };
14
- const trackedScopes = ['@sitecore', '@sitecore-cloudsdk', '@sitecore-feaas', '@sitecore-jss'];
15
- const dirs = fs_1.default.readdirSync('node_modules');
16
- dirs.forEach((dir) => {
17
- if (trackedScopes.includes(dir)) {
18
- const packageNames = fs_1.default.readdirSync(path_1.default.join('node_modules', dir));
19
- packageNames.forEach((pkg) => {
20
- try {
21
- const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join('node_modules', dir, pkg, 'package.json'), 'utf8'));
22
- metadata.packages[json.name] = json.version;
23
- }
24
- catch (e) {
25
- console.error(`Failed to read/parse package.json for ${pkg}`, e);
26
- }
27
- });
28
- }
29
- });
11
+ let queryResult = [];
12
+ try {
13
+ queryResult = JSON.parse((0, child_process_1.execSync)('npm query [name*=@sitecore] --workspaces false').toString());
14
+ }
15
+ catch (error) {
16
+ console.error('Failed to retrieve sitecore packages using npm query', error);
17
+ return metadata;
18
+ }
19
+ metadata.packages = getPackagesFromQueryResult(queryResult);
30
20
  return metadata;
31
21
  }
32
22
  exports.getMetadata = getMetadata;
23
+ /**
24
+ * Retrieve all packages of the tracked scopes with their exact versions
25
+ * @param {Package[]} scPackages list of packages
26
+ * @returns {Record<string, string>} an object with the packages with their exact versions
27
+ */
28
+ function getPackagesFromQueryResult(scPackages) {
29
+ const packages = {};
30
+ scPackages.forEach((scPackage) => {
31
+ if (trackedScopes.some((trackedScope) => scPackage.name.startsWith(trackedScope))) {
32
+ packages[scPackage.name] = scPackage.version;
33
+ }
34
+ });
35
+ return packages;
36
+ }
@@ -1,25 +1,32 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ import { execSync } from 'child_process';
2
+ const trackedScopes = ['@sitecore', '@sitecore-cloudsdk', '@sitecore-feaas', '@sitecore-jss'];
3
3
  /**
4
4
  * Get application metadata
5
5
  */
6
6
  export function getMetadata() {
7
7
  const metadata = { packages: {} };
8
- const trackedScopes = ['@sitecore', '@sitecore-cloudsdk', '@sitecore-feaas', '@sitecore-jss'];
9
- const dirs = fs.readdirSync('node_modules');
10
- dirs.forEach((dir) => {
11
- if (trackedScopes.includes(dir)) {
12
- const packageNames = fs.readdirSync(path.join('node_modules', dir));
13
- packageNames.forEach((pkg) => {
14
- try {
15
- const json = JSON.parse(fs.readFileSync(path.join('node_modules', dir, pkg, 'package.json'), 'utf8'));
16
- metadata.packages[json.name] = json.version;
17
- }
18
- catch (e) {
19
- console.error(`Failed to read/parse package.json for ${pkg}`, e);
20
- }
21
- });
8
+ let queryResult = [];
9
+ try {
10
+ queryResult = JSON.parse(execSync('npm query [name*=@sitecore] --workspaces false').toString());
11
+ }
12
+ catch (error) {
13
+ console.error('Failed to retrieve sitecore packages using npm query', error);
14
+ return metadata;
15
+ }
16
+ metadata.packages = getPackagesFromQueryResult(queryResult);
17
+ return metadata;
18
+ }
19
+ /**
20
+ * Retrieve all packages of the tracked scopes with their exact versions
21
+ * @param {Package[]} scPackages list of packages
22
+ * @returns {Record<string, string>} an object with the packages with their exact versions
23
+ */
24
+ function getPackagesFromQueryResult(scPackages) {
25
+ const packages = {};
26
+ scPackages.forEach((scPackage) => {
27
+ if (trackedScopes.some((trackedScope) => scPackage.name.startsWith(trackedScope))) {
28
+ packages[scPackage.name] = scPackage.version;
22
29
  }
23
30
  });
24
- return metadata;
31
+ return packages;
25
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-dev-tools",
3
- "version": "22.2.0-canary.8",
3
+ "version": "22.2.0-canary.80",
4
4
  "description": "Utilities to assist in the development and deployment of Sitecore JSS apps.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/parser": "^7.24.0",
36
- "@sitecore-jss/sitecore-jss": "^22.2.0-canary.8",
36
+ "@sitecore-jss/sitecore-jss": "^22.2.0-canary.80",
37
37
  "axios": "^1.3.2",
38
38
  "chalk": "^4.1.2",
39
39
  "chokidar": "^3.6.0",
@@ -86,7 +86,7 @@
86
86
  "typescript": "~4.9.5"
87
87
  },
88
88
  "types": "types/index.d.ts",
89
- "gitHead": "755525262fcb998452876d2f28a57d130e29731c",
89
+ "gitHead": "0ecca7f10712e929cfe4375ccfbd479020cd30fc",
90
90
  "files": [
91
91
  "dist",
92
92
  "types",