@sitecore-content-sdk/cli 2.0.0-canary.1 → 2.0.0-canary.12

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.
@@ -54,10 +54,14 @@ const path_1 = __importDefault(require("path"));
54
54
  const chalk_1 = __importDefault(require("chalk"));
55
55
  const child_process_1 = require("child_process");
56
56
  const tools = __importStar(require("@sitecore-content-sdk/content/tools"));
57
+ const core_1 = require("@sitecore-content-sdk/core");
58
+ const serverTools = __importStar(require("@sitecore-content-sdk/content/node-tools"));
57
59
  const inquirer_1 = __importDefault(require("inquirer"));
58
60
  const generate_map_1 = require("./generate-map");
59
61
  const load_config_1 = __importDefault(require("../../../utils/load-config"));
60
- let { getComponentSpec, getComponentList, getComponentSpecUrl } = tools;
62
+ let { getComponentSpec, getComponentSpecUrl } = tools;
63
+ let { getComponentList } = serverTools;
64
+ const { ERROR_MESSAGES } = core_1.constants;
61
65
  const unitMocks = (toolsModule) => {
62
66
  getComponentSpec = toolsModule.getComponentSpec;
63
67
  getComponentList = toolsModule.getComponentList;
@@ -147,7 +151,7 @@ function handler(argv) {
147
151
  let targetPath = targetPathArg;
148
152
  const cliConfig = (0, load_config_1.default)(config);
149
153
  if (!cliConfig.config) {
150
- console.error('The `sitecore.cli.config` file is missing a `config`. Please add it to use this command.');
154
+ console.error(ERROR_MESSAGES.MV_005('config'));
151
155
  return;
152
156
  }
153
157
  const { edgeUrl } = cliConfig.config.api.edge;
@@ -234,7 +238,7 @@ function handler(argv) {
234
238
  fs_1.default.renameSync(backupPath, resolvedFilePath);
235
239
  }
236
240
  const errorMessage = error instanceof Error ? error.message : String(error);
237
- console.error(chalk_1.default.red(`Failed to add component: ${errorMessage}`));
241
+ console.error(chalk_1.default.red(`Failed to add a generated component. ${errorMessage}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`));
238
242
  return;
239
243
  }
240
244
  });
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.builder = builder;
7
7
  exports.args = args;
8
8
  exports.handler = handler;
9
+ const core_1 = require("@sitecore-content-sdk/core");
9
10
  const watch_items_1 = require("../../../utils/watch-items");
10
11
  const load_config_1 = __importDefault(require("../../../utils/load-config"));
12
+ const { ERROR_MESSAGES } = core_1.constants;
11
13
  /**
12
14
  * @param {Argv} yargs
13
15
  */
@@ -40,7 +42,7 @@ function args(yargs) {
40
42
  function handler(argv) {
41
43
  const cliConfig = (0, load_config_1.default)(argv.config);
42
44
  if (!cliConfig.componentMap) {
43
- console.error('The `sitecore.cli.config` file is missing a `componentMap` configuration. Please add it to use this command.');
45
+ console.error(ERROR_MESSAGES.MV_005('componentMap'));
44
46
  return;
45
47
  }
46
48
  const componentMapGenerator = cliConfig.componentMap.generator;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.builder = builder;
7
7
  exports.args = args;
8
8
  exports.handler = handler;
9
- const tools_1 = require("@sitecore-content-sdk/content/tools");
9
+ const node_tools_1 = require("@sitecore-content-sdk/content/node-tools");
10
10
  const load_config_1 = __importDefault(require("../../../utils/load-config"));
11
11
  const config_1 = require("@sitecore-content-sdk/content/config");
12
12
  /**
@@ -67,5 +67,5 @@ dashes, or underscores. It can also contain slashes to indicate a subfolder`);
67
67
  const componentName = regExResult[2];
68
68
  const outputFolder = componentPath || 'src/components';
69
69
  const templateName = (_a = argv.templateName) !== null && _a !== void 0 ? _a : (argv.byoc ? config_1.ComponentTemplateType.BYOC : config_1.ComponentTemplateType.DEFAULT);
70
- (0, tools_1.scaffoldComponent)(outputFolder, componentName, templateName, cliConfig.scaffold.templates);
70
+ (0, node_tools_1.scaffoldComponent)(outputFolder, componentName, templateName, cliConfig.scaffold.templates);
71
71
  }
@@ -12,10 +12,14 @@ import path from 'path';
12
12
  import chalk from 'chalk';
13
13
  import { execSync } from 'child_process';
14
14
  import * as tools from '@sitecore-content-sdk/content/tools';
15
+ import { constants } from '@sitecore-content-sdk/core';
16
+ import * as serverTools from '@sitecore-content-sdk/content/node-tools';
15
17
  import inquirer from 'inquirer';
16
18
  import { handler as generateMapHandler } from './generate-map';
17
19
  import loadCliConfig from '../../../utils/load-config';
18
- let { getComponentSpec, getComponentList, getComponentSpecUrl } = tools;
20
+ let { getComponentSpec, getComponentSpecUrl } = tools;
21
+ let { getComponentList } = serverTools;
22
+ const { ERROR_MESSAGES } = constants;
19
23
  export const unitMocks = (toolsModule) => {
20
24
  getComponentSpec = toolsModule.getComponentSpec;
21
25
  getComponentList = toolsModule.getComponentList;
@@ -104,7 +108,7 @@ export function handler(argv) {
104
108
  let targetPath = targetPathArg;
105
109
  const cliConfig = loadCliConfig(config);
106
110
  if (!cliConfig.config) {
107
- console.error('The `sitecore.cli.config` file is missing a `config`. Please add it to use this command.');
111
+ console.error(ERROR_MESSAGES.MV_005('config'));
108
112
  return;
109
113
  }
110
114
  const { edgeUrl } = cliConfig.config.api.edge;
@@ -191,7 +195,7 @@ export function handler(argv) {
191
195
  fs.renameSync(backupPath, resolvedFilePath);
192
196
  }
193
197
  const errorMessage = error instanceof Error ? error.message : String(error);
194
- console.error(chalk.red(`Failed to add component: ${errorMessage}`));
198
+ console.error(chalk.red(`Failed to add a generated component. ${errorMessage}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`));
195
199
  return;
196
200
  }
197
201
  });
@@ -1,5 +1,7 @@
1
+ import { constants } from '@sitecore-content-sdk/core';
1
2
  import { watchItems } from '../../../utils/watch-items';
2
3
  import loadCliConfig from '../../../utils/load-config';
4
+ const { ERROR_MESSAGES } = constants;
3
5
  /**
4
6
  * @param {Argv} yargs
5
7
  */
@@ -32,7 +34,7 @@ export function args(yargs) {
32
34
  export function handler(argv) {
33
35
  const cliConfig = loadCliConfig(argv.config);
34
36
  if (!cliConfig.componentMap) {
35
- console.error('The `sitecore.cli.config` file is missing a `componentMap` configuration. Please add it to use this command.');
37
+ console.error(ERROR_MESSAGES.MV_005('componentMap'));
36
38
  return;
37
39
  }
38
40
  const componentMapGenerator = cliConfig.componentMap.generator;
@@ -1,4 +1,4 @@
1
- import { scaffoldComponent } from '@sitecore-content-sdk/content/tools';
1
+ import { scaffoldComponent } from '@sitecore-content-sdk/content/node-tools';
2
2
  import loadCliConfig from '../../../utils/load-config';
3
3
  import { ComponentTemplateType } from '@sitecore-content-sdk/content/config';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/cli",
3
- "version": "2.0.0-canary.1",
3
+ "version": "2.0.0-canary.12",
4
4
  "description": "Sitecore Content SDK CLI",
5
5
  "main": "dist/cjs/cli.js",
6
6
  "module": "dist/esm/cli.js",
@@ -34,7 +34,8 @@
34
34
  "url": "https://github.com/sitecore/content-sdk/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@sitecore-content-sdk/content": "2.0.0-canary.1",
37
+ "@sitecore-content-sdk/content": "2.0.0-canary.12",
38
+ "@sitecore-content-sdk/core": "2.0.0-canary.12",
38
39
  "chokidar": "^4.0.3",
39
40
  "dotenv": "^16.5.0",
40
41
  "dotenv-expand": "^12.0.2",
@@ -71,7 +72,7 @@
71
72
  "ts-node": "^10.9.1",
72
73
  "typescript": "~5.8.3"
73
74
  },
74
- "gitHead": "b457ff6e0b17787c66803a15b50da0d3ad6e4200",
75
+ "gitHead": "4a26005860f4931f25d8c63d765a030e04a5b1f4",
75
76
  "files": [
76
77
  "dist",
77
78
  "types"
@@ -1,6 +1,22 @@
1
1
  import { Argv } from 'yargs';
2
2
  import * as tools from '@sitecore-content-sdk/content/tools';
3
- export declare const unitMocks: (toolsModule: Pick<typeof tools, "getComponentSpec" | "getComponentList" | "getComponentSpecUrl">) => void;
3
+ declare let getComponentSpec: ({ componentId, edgeUrl, targetPath, token, }: {
4
+ edgeUrl?: string;
5
+ targetPath?: string;
6
+ componentId: string;
7
+ token: string;
8
+ }) => Promise<import("@sitecore-content-sdk/content/types/tools/codegen/component-generation").ComponentSpec>, getComponentSpecUrl: ({ componentId, edgeUrl, targetPath, token, }: {
9
+ edgeUrl?: string;
10
+ targetPath?: string;
11
+ componentId: string;
12
+ token: string;
13
+ }) => string;
14
+ declare let getComponentList: (paths: string[], exclude?: string[], includeVariants?: boolean) => tools.ComponentFile[];
15
+ export declare const unitMocks: (toolsModule: {
16
+ getComponentSpec: typeof getComponentSpec;
17
+ getComponentList: typeof getComponentList;
18
+ getComponentSpecUrl: typeof getComponentSpecUrl;
19
+ }) => void;
4
20
  type AddArgs = {
5
21
  /**
6
22
  * The unique identifier of the newly created component.
@@ -16,12 +32,12 @@ type AddArgs = {
16
32
  targetPath?: string;
17
33
  /**
18
34
  * If true, skips the component map generation.
19
- * Default: false.
35
+ * Default: `false`.
20
36
  */
21
37
  skipComponentMap?: boolean;
22
38
  /**
23
39
  * If true, overwrites the existing component.
24
- * Default: false.
40
+ * Default: `false`.
25
41
  */
26
42
  overwrite?: boolean;
27
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/scripts/project/component/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAK7B,OAAO,KAAK,KAAK,MAAM,qCAAqC,CAAC;AAO7D,eAAO,MAAM,SAAS,GACpB,aAAa,IAAI,CAAC,OAAO,KAAK,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,SAKjG,CAAC;AAEF,KAAK,OAAO,GAAG;IACb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,IAAI,CAAC,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1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-map.d.ts","sourceRoot":"","sources":["../../../../src/scripts/project/component/generate-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAI7B;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,4BAOtD;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC;;;;GAiBnD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,kBAAkB,QAqC/C"}
1
+ {"version":3,"file":"generate-map.d.ts","sourceRoot":"","sources":["../../../../src/scripts/project/component/generate-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAO7B;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,4BAOtD;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC;;;;GAiBnD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,kBAAkB,QAqC/C"}