@sitecore-content-sdk/cli 1.3.0-canary.9 → 1.3.0
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.txt +202 -202
- package/README.md +5 -5
- package/dist/cjs/bin/sitecore-tools.js +77 -77
- package/dist/cjs/cli.js +69 -69
- package/dist/cjs/scripts/index.js +40 -40
- package/dist/cjs/scripts/project/build.js +42 -42
- package/dist/cjs/scripts/project/component/add.js +241 -236
- package/dist/cjs/scripts/project/component/generate-map.js +70 -68
- package/dist/cjs/scripts/project/component/index.js +57 -57
- package/dist/cjs/scripts/project/component/scaffold.js +69 -66
- package/dist/cjs/scripts/project/index.js +56 -56
- package/dist/cjs/utils/load-config.js +42 -42
- package/dist/cjs/utils/process-env.js +70 -70
- package/dist/cjs/utils/watch-items.js +18 -18
- package/dist/esm/cli.js +63 -63
- package/dist/esm/scripts/index.js +4 -4
- package/dist/esm/scripts/project/build.js +35 -35
- package/dist/esm/scripts/project/component/add.js +198 -193
- package/dist/esm/scripts/project/component/generate-map.js +62 -60
- package/dist/esm/scripts/project/component/index.js +21 -21
- package/dist/esm/scripts/project/component/scaffold.js +61 -58
- package/dist/esm/scripts/project/index.js +20 -20
- package/dist/esm/utils/load-config.js +36 -36
- package/dist/esm/utils/process-env.js +31 -31
- package/dist/esm/utils/watch-items.js +12 -12
- package/package.json +79 -79
- package/types/bin/sitecore-tools.d.ts +3 -2
- package/types/bin/sitecore-tools.d.ts.map +1 -0
- package/types/cli.d.ts +14 -13
- package/types/cli.d.ts.map +1 -0
- package/types/scripts/index.d.ts +3 -2
- package/types/scripts/index.d.ts.map +1 -0
- package/types/scripts/project/build.d.ts +25 -24
- package/types/scripts/project/build.d.ts.map +1 -0
- package/types/scripts/project/component/add.d.ts +59 -58
- package/types/scripts/project/component/add.d.ts.map +1 -0
- package/types/scripts/project/component/generate-map.d.ts +33 -32
- package/types/scripts/project/component/generate-map.d.ts.map +1 -0
- package/types/scripts/project/component/index.d.ts +6 -5
- package/types/scripts/project/component/index.d.ts.map +1 -0
- package/types/scripts/project/component/scaffold.d.ts +45 -44
- package/types/scripts/project/component/scaffold.d.ts.map +1 -0
- package/types/scripts/project/index.d.ts +6 -5
- package/types/scripts/project/index.d.ts.map +1 -0
- package/types/utils/load-config.d.ts +9 -8
- package/types/utils/load-config.d.ts.map +1 -0
- package/types/utils/process-env.d.ts +9 -8
- package/types/utils/process-env.d.ts.map +1 -0
- package/types/utils/watch-items.d.ts +7 -6
- package/types/utils/watch-items.d.ts.map +1 -0
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.builder = builder;
|
|
37
|
-
const scaffold = __importStar(require("./scaffold"));
|
|
38
|
-
const generateMap = __importStar(require("./generate-map"));
|
|
39
|
-
/**
|
|
40
|
-
* @param {Argv} yargs
|
|
41
|
-
*/
|
|
42
|
-
function builder(yargs) {
|
|
43
|
-
return yargs.command({
|
|
44
|
-
command: 'component',
|
|
45
|
-
describe: 'Performs component level operations',
|
|
46
|
-
builder: (_yargs) => {
|
|
47
|
-
_yargs = _yargs
|
|
48
|
-
.command([scaffold, generateMap])
|
|
49
|
-
.strict()
|
|
50
|
-
.demandCommand(1, 'You need to specify a command to run');
|
|
51
|
-
_yargs = scaffold.builder(_yargs);
|
|
52
|
-
_yargs = generateMap.builder(_yargs);
|
|
53
|
-
return _yargs;
|
|
54
|
-
},
|
|
55
|
-
handler: () => { },
|
|
56
|
-
});
|
|
57
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.builder = builder;
|
|
37
|
+
const scaffold = __importStar(require("./scaffold"));
|
|
38
|
+
const generateMap = __importStar(require("./generate-map"));
|
|
39
|
+
/**
|
|
40
|
+
* @param {Argv} yargs
|
|
41
|
+
*/
|
|
42
|
+
function builder(yargs) {
|
|
43
|
+
return yargs.command({
|
|
44
|
+
command: ['component', 'c'],
|
|
45
|
+
describe: 'Performs component level operations',
|
|
46
|
+
builder: (_yargs) => {
|
|
47
|
+
_yargs = _yargs
|
|
48
|
+
.command([scaffold, generateMap])
|
|
49
|
+
.strict()
|
|
50
|
+
.demandCommand(1, 'You need to specify a command to run');
|
|
51
|
+
_yargs = scaffold.builder(_yargs);
|
|
52
|
+
_yargs = generateMap.builder(_yargs);
|
|
53
|
+
return _yargs;
|
|
54
|
+
},
|
|
55
|
+
handler: () => { },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -1,68 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.builder = builder;
|
|
7
|
-
exports.args = args;
|
|
8
|
-
exports.handler = handler;
|
|
9
|
-
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
10
|
-
const load_config_1 = __importDefault(require("../../../utils/load-config"));
|
|
11
|
-
const config_1 = require("@sitecore-content-sdk/core/config");
|
|
12
|
-
/**
|
|
13
|
-
* @param {Argv} yargs
|
|
14
|
-
*/
|
|
15
|
-
function builder(yargs) {
|
|
16
|
-
return yargs.command('scaffold <componentName>', 'Scaffolds a new component', args, handler);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @param {Argv} yargs
|
|
20
|
-
*/
|
|
21
|
-
function args(yargs) {
|
|
22
|
-
return yargs
|
|
23
|
-
.positional('componentName', {
|
|
24
|
-
requiresArg: true,
|
|
25
|
-
positional: true,
|
|
26
|
-
type: 'string',
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.builder = builder;
|
|
7
|
+
exports.args = args;
|
|
8
|
+
exports.handler = handler;
|
|
9
|
+
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
10
|
+
const load_config_1 = __importDefault(require("../../../utils/load-config"));
|
|
11
|
+
const config_1 = require("@sitecore-content-sdk/core/config");
|
|
12
|
+
/**
|
|
13
|
+
* @param {Argv} yargs
|
|
14
|
+
*/
|
|
15
|
+
function builder(yargs) {
|
|
16
|
+
return yargs.command(['scaffold <componentName>', 's <componentName>'], 'Scaffolds a new component', args, handler);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param {Argv} yargs
|
|
20
|
+
*/
|
|
21
|
+
function args(yargs) {
|
|
22
|
+
return yargs
|
|
23
|
+
.positional('componentName', {
|
|
24
|
+
requiresArg: true,
|
|
25
|
+
positional: true,
|
|
26
|
+
type: 'string',
|
|
27
27
|
describe: `Name of the component to scaffold. Component name should start with an uppercase letter and contain only letters, numbers,
|
|
28
|
-
dashes, or underscores. It can also contain slashes to indicate a subfolder. Example: MyComponent or MyFolder/MyComponent. If no subfolder is specified, the component will be created under 'src/components'.`,
|
|
29
|
-
})
|
|
30
|
-
.option('config', {
|
|
31
|
-
requiresArg: false,
|
|
32
|
-
type: 'string',
|
|
33
|
-
describe: 'Path to the `sitecore.cli.config` file. Supports both JavaScript (`.js`) and TypeScript (`.ts`) formats',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
28
|
+
dashes, or underscores. It can also contain slashes to indicate a subfolder. Example: MyComponent or MyFolder/MyComponent. If no subfolder is specified, the component will be created under 'src/components'.`,
|
|
29
|
+
})
|
|
30
|
+
.option('config', {
|
|
31
|
+
requiresArg: false,
|
|
32
|
+
type: 'string',
|
|
33
|
+
describe: 'Path to the `sitecore.cli.config` file. Supports both JavaScript (`.js`) and TypeScript (`.ts`) formats',
|
|
34
|
+
alias: 'c',
|
|
35
|
+
})
|
|
36
|
+
.option('templateName', {
|
|
37
|
+
requiresArg: false,
|
|
38
|
+
type: 'string',
|
|
39
|
+
describe: 'Name of the template that will be used to scaffold the component. Can be configured in the cli.config.',
|
|
40
|
+
alias: 't',
|
|
41
|
+
})
|
|
42
|
+
.option('byoc', {
|
|
43
|
+
requiresArg: false,
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
describe: 'If true, scaffolds a byoc component.',
|
|
46
|
+
default: false,
|
|
47
|
+
alias: 'b',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Handler for the scaffold command.
|
|
52
|
+
* @param {ScaffoldArgs} argv - The arguments passed to the command.
|
|
53
|
+
*/
|
|
54
|
+
function handler(argv) {
|
|
55
|
+
var _a;
|
|
56
|
+
if (!argv.componentName) {
|
|
57
|
+
throw new Error('Component name is required. Usage: sitecore-tools scaffold <ComponentName>');
|
|
58
|
+
}
|
|
59
|
+
const nameParamFormat = new RegExp(/^((?:[\w\-]+\/)*)([A-Z][\w-]+)$/);
|
|
60
|
+
const regExResult = nameParamFormat.exec(argv.componentName);
|
|
61
|
+
if (regExResult === null) {
|
|
59
62
|
throw new Error(`Component name should start with an uppercase letter and contain only letters, numbers,
|
|
60
|
-
dashes, or underscores. It can also contain slashes to indicate a subfolder`);
|
|
61
|
-
}
|
|
62
|
-
const cliConfig = (0, load_config_1.default)(argv.config);
|
|
63
|
-
const componentPath = regExResult[1];
|
|
64
|
-
const componentName = regExResult[2];
|
|
65
|
-
const outputFolder = componentPath || 'src/components';
|
|
66
|
-
const templateName = (_a = argv.templateName) !== null && _a !== void 0 ? _a : (argv.byoc ? config_1.ComponentTemplateType.BYOC : config_1.ComponentTemplateType.DEFAULT);
|
|
67
|
-
(0, tools_1.scaffoldComponent)(outputFolder, componentName, templateName, cliConfig.scaffold.templates);
|
|
68
|
-
}
|
|
63
|
+
dashes, or underscores. It can also contain slashes to indicate a subfolder`);
|
|
64
|
+
}
|
|
65
|
+
const cliConfig = (0, load_config_1.default)(argv.config);
|
|
66
|
+
const componentPath = regExResult[1];
|
|
67
|
+
const componentName = regExResult[2];
|
|
68
|
+
const outputFolder = componentPath || 'src/components';
|
|
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);
|
|
71
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.builder = builder;
|
|
37
|
-
const build = __importStar(require("./build"));
|
|
38
|
-
const component = __importStar(require("./component"));
|
|
39
|
-
/**
|
|
40
|
-
* @param {Argv} yargs
|
|
41
|
-
*/
|
|
42
|
-
function builder(yargs) {
|
|
43
|
-
return yargs.command({
|
|
44
|
-
command: 'project',
|
|
45
|
-
describe: 'Performs project level operations',
|
|
46
|
-
builder: (_yargs) => {
|
|
47
|
-
_yargs = _yargs
|
|
48
|
-
.command([build, component])
|
|
49
|
-
.strict()
|
|
50
|
-
.demandCommand(1, 'You need to specify a command to run');
|
|
51
|
-
_yargs = component.builder(_yargs);
|
|
52
|
-
return _yargs;
|
|
53
|
-
},
|
|
54
|
-
handler: () => { },
|
|
55
|
-
});
|
|
56
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.builder = builder;
|
|
37
|
+
const build = __importStar(require("./build"));
|
|
38
|
+
const component = __importStar(require("./component"));
|
|
39
|
+
/**
|
|
40
|
+
* @param {Argv} yargs
|
|
41
|
+
*/
|
|
42
|
+
function builder(yargs) {
|
|
43
|
+
return yargs.command({
|
|
44
|
+
command: ['project', 'p'],
|
|
45
|
+
describe: 'Performs project level operations',
|
|
46
|
+
builder: (_yargs) => {
|
|
47
|
+
_yargs = _yargs
|
|
48
|
+
.command([build, component])
|
|
49
|
+
.strict()
|
|
50
|
+
.demandCommand(1, 'You need to specify a command to run');
|
|
51
|
+
_yargs = component.builder(_yargs);
|
|
52
|
+
return _yargs;
|
|
53
|
+
},
|
|
54
|
+
handler: () => { },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = loadCliConfig;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const process_env_1 = __importDefault(require("./process-env"));
|
|
10
|
-
const tsx = require('tsx/cjs/api');
|
|
11
|
-
/**
|
|
12
|
-
* Loads Sitecore Content SDK CLI configuration from the specified file.
|
|
13
|
-
* @param {string} [configFile] - The path to the configuration file.
|
|
14
|
-
* @returns {SitecoreCliConfig} The default export from the configuration file.
|
|
15
|
-
* @throws Will throw an error if the configuration file does not exist or does not have a default export.
|
|
16
|
-
*/
|
|
17
|
-
function loadCliConfig(configFile) {
|
|
18
|
-
// If no config file is provided, try to load the default config file.
|
|
19
|
-
if (!configFile) {
|
|
20
|
-
configFile = './sitecore.cli.config.ts';
|
|
21
|
-
if (!fs_1.default.existsSync(path_1.default.resolve(process.cwd(), configFile))) {
|
|
22
|
-
configFile = './sitecore.cli.config.js';
|
|
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
|
-
}
|
|
34
|
-
let cliConfig;
|
|
35
|
-
try {
|
|
36
|
-
cliConfig = tsx.require(path_1.default.resolve(process.cwd(), configFile), __filename);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
throw `Error while trying to load the cli configuration from ${configFile}. Error message: ${e.message}`;
|
|
40
|
-
}
|
|
41
|
-
return cliConfig.default;
|
|
42
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = loadCliConfig;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const process_env_1 = __importDefault(require("./process-env"));
|
|
10
|
+
const tsx = require('tsx/cjs/api');
|
|
11
|
+
/**
|
|
12
|
+
* Loads Sitecore Content SDK CLI configuration from the specified file.
|
|
13
|
+
* @param {string} [configFile] - The path to the configuration file.
|
|
14
|
+
* @returns {SitecoreCliConfig} The default export from the configuration file.
|
|
15
|
+
* @throws Will throw an error if the configuration file does not exist or does not have a default export.
|
|
16
|
+
*/
|
|
17
|
+
function loadCliConfig(configFile) {
|
|
18
|
+
// If no config file is provided, try to load the default config file.
|
|
19
|
+
if (!configFile) {
|
|
20
|
+
configFile = './sitecore.cli.config.ts';
|
|
21
|
+
if (!fs_1.default.existsSync(path_1.default.resolve(process.cwd(), configFile))) {
|
|
22
|
+
configFile = './sitecore.cli.config.js';
|
|
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
|
+
}
|
|
34
|
+
let cliConfig;
|
|
35
|
+
try {
|
|
36
|
+
cliConfig = tsx.require(path_1.default.resolve(process.cwd(), configFile), __filename);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw `Error while trying to load the cli configuration from ${configFile}. Error message: ${e.message}`;
|
|
40
|
+
}
|
|
41
|
+
return cliConfig.default;
|
|
42
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.default = processEnv;
|
|
40
|
-
const path_1 = __importDefault(require("path"));
|
|
41
|
-
const dotenv = __importStar(require("dotenv"));
|
|
42
|
-
const dotenv_expand_1 = __importDefault(require("dotenv-expand"));
|
|
43
|
-
const config_cli_1 = require("@sitecore-content-sdk/core/config-cli");
|
|
44
|
-
/**
|
|
45
|
-
* Loads and processes environment variables from `.env` files in the specified directory.
|
|
46
|
-
* It supports multiple `.env` files, including
|
|
47
|
-
* environment-specific files (e.g., `.env.development`, `.env.production`) and local overrides
|
|
48
|
-
* (e.g., `.env.local`, `.env.development.local`).
|
|
49
|
-
* @param {string} dir - The directory to search for `.env` files.
|
|
50
|
-
*/
|
|
51
|
-
function processEnv(dir) {
|
|
52
|
-
// replicate Next.js handling/behavior, but without a default NODE_ENV
|
|
53
|
-
// https://github.com/vercel/next.js/blob/v10.0.5/packages/next-env/index.ts#L80-L90
|
|
54
|
-
const mode = process.env.NODE_ENV;
|
|
55
|
-
const dotenvFiles = [
|
|
56
|
-
mode && `.env.${mode}.local`,
|
|
57
|
-
// Don't include `.env.local` for `test` environment
|
|
58
|
-
// since normally you expect tests to produce the same
|
|
59
|
-
// results for everyone
|
|
60
|
-
mode !== 'test' && '.env.local',
|
|
61
|
-
mode && `.env.${mode}`,
|
|
62
|
-
'.env',
|
|
63
|
-
].filter(Boolean);
|
|
64
|
-
// Set the environment variable to indicate that the application is running in CLI mode
|
|
65
|
-
process.env[config_cli_1.SITECORE_CLI_MODE_ENV_VAR] = 'true';
|
|
66
|
-
// inspired by https://github.com/entropitor/dotenv-cli/blob/v4.0.0/cli.js#L53-L55
|
|
67
|
-
dotenvFiles.forEach(function (env) {
|
|
68
|
-
dotenv_expand_1.default.expand(dotenv.config({ path: path_1.default.resolve(dir, env) }));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = processEnv;
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const dotenv = __importStar(require("dotenv"));
|
|
42
|
+
const dotenv_expand_1 = __importDefault(require("dotenv-expand"));
|
|
43
|
+
const config_cli_1 = require("@sitecore-content-sdk/core/config-cli");
|
|
44
|
+
/**
|
|
45
|
+
* Loads and processes environment variables from `.env` files in the specified directory.
|
|
46
|
+
* It supports multiple `.env` files, including
|
|
47
|
+
* environment-specific files (e.g., `.env.development`, `.env.production`) and local overrides
|
|
48
|
+
* (e.g., `.env.local`, `.env.development.local`).
|
|
49
|
+
* @param {string} dir - The directory to search for `.env` files.
|
|
50
|
+
*/
|
|
51
|
+
function processEnv(dir) {
|
|
52
|
+
// replicate Next.js handling/behavior, but without a default NODE_ENV
|
|
53
|
+
// https://github.com/vercel/next.js/blob/v10.0.5/packages/next-env/index.ts#L80-L90
|
|
54
|
+
const mode = process.env.NODE_ENV;
|
|
55
|
+
const dotenvFiles = [
|
|
56
|
+
mode && `.env.${mode}.local`,
|
|
57
|
+
// Don't include `.env.local` for `test` environment
|
|
58
|
+
// since normally you expect tests to produce the same
|
|
59
|
+
// results for everyone
|
|
60
|
+
mode !== 'test' && '.env.local',
|
|
61
|
+
mode && `.env.${mode}`,
|
|
62
|
+
'.env',
|
|
63
|
+
].filter(Boolean);
|
|
64
|
+
// Set the environment variable to indicate that the application is running in CLI mode
|
|
65
|
+
process.env[config_cli_1.SITECORE_CLI_MODE_ENV_VAR] = 'true';
|
|
66
|
+
// inspired by https://github.com/entropitor/dotenv-cli/blob/v4.0.0/cli.js#L53-L55
|
|
67
|
+
dotenvFiles.forEach(function (env) {
|
|
68
|
+
dotenv_expand_1.default.expand(dotenv.config({ path: path_1.default.resolve(dir, env) }));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.watchItems = watchItems;
|
|
7
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
-
/**
|
|
9
|
-
* Run watch mode, watching on @var paths
|
|
10
|
-
* @param {string[]} paths paths to watch by chokidar
|
|
11
|
-
* @param {Function<void>} cb callback to run on file change
|
|
12
|
-
*/
|
|
13
|
-
function watchItems(paths, cb) {
|
|
14
|
-
chokidar_1.default
|
|
15
|
-
.watch(paths, { ignoreInitial: true, awaitWriteFinish: true })
|
|
16
|
-
.on('add', cb)
|
|
17
|
-
.on('unlink', cb);
|
|
18
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watchItems = watchItems;
|
|
7
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
+
/**
|
|
9
|
+
* Run watch mode, watching on @var paths
|
|
10
|
+
* @param {string[]} paths paths to watch by chokidar
|
|
11
|
+
* @param {Function<void>} cb callback to run on file change
|
|
12
|
+
*/
|
|
13
|
+
function watchItems(paths, cb) {
|
|
14
|
+
chokidar_1.default
|
|
15
|
+
.watch(paths, { ignoreInitial: true, awaitWriteFinish: true })
|
|
16
|
+
.on('add', cb)
|
|
17
|
+
.on('unlink', cb);
|
|
18
|
+
}
|