@sitecore-content-sdk/cli 0.1.0-beta.23 → 0.1.0-beta.25

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.
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.builder = builder;
7
7
  exports.args = args;
8
8
  exports.handler = handler;
9
- const path_1 = __importDefault(require("path"));
10
9
  const tools_1 = require("@sitecore-content-sdk/core/tools");
11
10
  const load_config_1 = __importDefault(require("../utils/load-config"));
12
11
  const config_1 = require("@sitecore-content-sdk/core/config");
@@ -63,8 +62,7 @@ dashes, or underscores. It can also contain slashes to indicate a subfolder`);
63
62
  const cliConfig = (0, load_config_1.default)(argv.config);
64
63
  const componentPath = regExResult[1];
65
64
  const componentName = regExResult[2];
66
- const filename = `${componentName}.tsx`;
67
- const outputFilePath = path_1.default.join(componentPath || 'src/components', filename);
65
+ const outputFolder = componentPath || 'src/components';
68
66
  const templateName = (_a = argv.templateName) !== null && _a !== void 0 ? _a : (argv.byoc ? config_1.ComponentTemplateType.BYOC : config_1.ComponentTemplateType.DEFAULT);
69
- (0, tools_1.scaffoldComponent)(outputFilePath, componentName, templateName, cliConfig.scaffold.templates);
67
+ (0, tools_1.scaffoldComponent)(outputFolder, componentName, templateName, cliConfig.scaffold.templates);
70
68
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = loadCliConfig;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
+ const process_env_1 = __importDefault(require("./process-env"));
9
10
  const tsx = require('tsx/cjs/api');
10
11
  /**
11
12
  * Loads Sitecore Content SDK CLI configuration from the specified file.
@@ -21,6 +22,15 @@ function loadCliConfig(configFile) {
21
22
  configFile = './sitecore.cli.config.js';
22
23
  }
23
24
  }
25
+ else {
26
+ // configuration file/filepath has been provided
27
+ // the env variables have been already loaded from the current working directory, however the current command may be running outside of a context of a project
28
+ // if so try loading the env vars from the directory of the provided config file
29
+ const configFileDirectory = path_1.default.dirname(path_1.default.resolve(process.cwd(), configFile));
30
+ if (process.cwd() !== configFileDirectory) {
31
+ (0, process_env_1.default)(configFileDirectory);
32
+ }
33
+ }
24
34
  let cliConfig;
25
35
  try {
26
36
  cliConfig = tsx.require(path_1.default.resolve(process.cwd(), configFile), __filename);
@@ -1,4 +1,3 @@
1
- import path from 'path';
2
1
  import { scaffoldComponent } from '@sitecore-content-sdk/core/tools';
3
2
  import loadCliConfig from '../utils/load-config';
4
3
  import { ComponentTemplateType } from '@sitecore-content-sdk/core/config';
@@ -55,8 +54,7 @@ dashes, or underscores. It can also contain slashes to indicate a subfolder`);
55
54
  const cliConfig = loadCliConfig(argv.config);
56
55
  const componentPath = regExResult[1];
57
56
  const componentName = regExResult[2];
58
- const filename = `${componentName}.tsx`;
59
- const outputFilePath = path.join(componentPath || 'src/components', filename);
57
+ const outputFolder = componentPath || 'src/components';
60
58
  const templateName = (_a = argv.templateName) !== null && _a !== void 0 ? _a : (argv.byoc ? ComponentTemplateType.BYOC : ComponentTemplateType.DEFAULT);
61
- scaffoldComponent(outputFilePath, componentName, templateName, cliConfig.scaffold.templates);
59
+ scaffoldComponent(outputFolder, componentName, templateName, cliConfig.scaffold.templates);
62
60
  }
@@ -1,5 +1,6 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
+ import processEnv from './process-env';
3
4
  const tsx = require('tsx/cjs/api');
4
5
  /**
5
6
  * Loads Sitecore Content SDK CLI configuration from the specified file.
@@ -15,6 +16,15 @@ export default function loadCliConfig(configFile) {
15
16
  configFile = './sitecore.cli.config.js';
16
17
  }
17
18
  }
19
+ else {
20
+ // configuration file/filepath has been provided
21
+ // the env variables have been already loaded from the current working directory, however the current command may be running outside of a context of a project
22
+ // if so try loading the env vars from the directory of the provided config file
23
+ const configFileDirectory = path.dirname(path.resolve(process.cwd(), configFile));
24
+ if (process.cwd() !== configFileDirectory) {
25
+ processEnv(configFileDirectory);
26
+ }
27
+ }
18
28
  let cliConfig;
19
29
  try {
20
30
  cliConfig = tsx.require(path.resolve(process.cwd(), configFile), __filename);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/cli",
3
- "version": "0.1.0-beta.23",
3
+ "version": "0.1.0-beta.25",
4
4
  "description": "Sitecore JSS command-line",
5
5
  "main": "dist/cjs/cli.js",
6
6
  "module": "dist/esm/cli.js",
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/sitecore/jss/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@sitecore-content-sdk/core": "0.1.0-beta.23",
37
+ "@sitecore-content-sdk/core": "0.1.0-beta.25",
38
38
  "dotenv": "^16.4.7",
39
39
  "dotenv-expand": "^12.0.1",
40
40
  "resolve": "^1.22.10",
@@ -61,7 +61,7 @@
61
61
  "ts-node": "^10.9.1",
62
62
  "typescript": "~5.7.3"
63
63
  },
64
- "gitHead": "e51a9eb11fceedefb6f378a5e8427cac40f05784",
64
+ "gitHead": "68a72d5756c881644e1ea36b853af1e0843ca938",
65
65
  "files": [
66
66
  "dist",
67
67
  "types"