@squiz/dxp-cli-next 0.0.0-development

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/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # DXP
2
+
3
+ ## Not a tool yet, install wont work
4
+
5
+ > DXP command line tool
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @squiz-dxp
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ Usage: dxp [options] [command]
17
+
18
+ dxp commands
19
+
20
+ Options:
21
+ -V, --version output the version number
22
+ -h, --help display help for command
23
+
24
+ Commands:
25
+ auth log into the sxc
26
+ td Template deployment commands
27
+ ```
package/bin/dxp.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ require('../lib/dxp.js');
@@ -0,0 +1,17 @@
1
+ import execa from 'execa';
2
+ declare type RunOptions = {
3
+ nodeOptions?: string;
4
+ nodePath?: string;
5
+ timeout?: number;
6
+ expectedFailure?: boolean;
7
+ };
8
+ declare type SpawnOptions = RunOptions & {
9
+ cwd: string;
10
+ };
11
+ declare type SpawnFunction<T> = (execPath: string, args: string[], options: SpawnOptions) => T;
12
+ /**
13
+ * Helper function to run CLI command in a given folder
14
+ */
15
+ export declare function runCLI(dir: string, args?: string[], options?: RunOptions): execa.ExecaSyncReturnValue;
16
+ export declare const spawnScript: SpawnFunction<execa.ExecaSyncReturnValue>;
17
+ export {};
@@ -0,0 +1,53 @@
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.spawnScript = exports.runCLI = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const execa_1 = __importDefault(require("execa"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const TEST_CLI_PATH = path_1.default.resolve(__dirname, './integration/bin.js');
11
+ /**
12
+ * Helper function to run CLI command in a given folder
13
+ */
14
+ function runCLI(dir, args, options = {
15
+ expectedFailure: false,
16
+ }) {
17
+ return (0, exports.spawnScript)(process.execPath, [TEST_CLI_PATH, ...(args || [])], Object.assign(Object.assign({}, options), { cwd: dir }));
18
+ }
19
+ exports.runCLI = runCLI;
20
+ const spawnScript = (execPath, args, options) => {
21
+ const result = execa_1.default.sync(execPath, args, getExecaOptions(options));
22
+ handleTestFailure(execPath, options, result, args);
23
+ return result;
24
+ };
25
+ exports.spawnScript = spawnScript;
26
+ function getExecaOptions(options) {
27
+ const isRelative = !path_1.default.isAbsolute(options.cwd);
28
+ const cwd = isRelative ? path_1.default.resolve(__dirname, options.cwd) : options.cwd;
29
+ const env = Object.assign({}, process.env, { FORCE_COLOR: '0' });
30
+ if (options.nodeOptions) {
31
+ env.NODE_OPTIONS = options.nodeOptions;
32
+ }
33
+ if (options.nodePath) {
34
+ env.NODE_PATH = options.nodePath;
35
+ }
36
+ return {
37
+ cwd,
38
+ env,
39
+ reject: false,
40
+ timeout: options.timeout || 0,
41
+ };
42
+ }
43
+ function handleTestFailure(cmd, options, result, args) {
44
+ if (!options.expectedFailure && result.code !== 0) {
45
+ console.log(`Running ${cmd} command failed for unexpected reason. Here's more info:
46
+ ${chalk_1.default.bold('cmd:')} ${cmd}
47
+ ${chalk_1.default.bold('options:')} ${JSON.stringify(options)}
48
+ ${chalk_1.default.bold('args:')} ${(args || []).join(' ')}
49
+ ${chalk_1.default.bold('stderr:')} ${result.stderr}
50
+ ${chalk_1.default.bold('stdout:')} ${result.stdout}
51
+ ${chalk_1.default.bold('code:')} ${result.code}`);
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const helpers_1 = require("../helpers");
4
+ describe('my-command', () => {
5
+ it('should display the help contents', () => {
6
+ const { stdout } = (0, helpers_1.runCLI)(process.cwd(), ['--help']);
7
+ expect(stdout).toContain('Usage: my-command [options]');
8
+ });
9
+ });
File without changes
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ describe('cli', () => {
3
+ it('should exist', () => {
4
+ const cli = require('../../src/cli');
5
+ expect(cli).toBeTruthy();
6
+ });
7
+ });
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ declare const _default: Command;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ exports.default = new commander_1.Command('identity')
5
+ .command('identity', 'returns the currently logged in users details')
6
+ .action(() => {
7
+ console.log('getting identity');
8
+ });
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ declare const authCommand: Command;
3
+ export default authCommand;
@@ -0,0 +1,11 @@
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
+ const commander_1 = require("commander");
7
+ const login_1 = __importDefault(require("./login"));
8
+ const authCommand = new commander_1.Command('auth');
9
+ authCommand.description('log into the sxc').addCommand(login_1.default);
10
+ //.addCommand(identityCommand);
11
+ exports.default = authCommand;
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ declare const _default: Command;
3
+ export default _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ exports.default = new commander_1.Command('login')
5
+ .name('login')
6
+ .argument('<username>', 'sxc username')
7
+ .argument('<password>', 'sxc password')
8
+ .action((username, password) => {
9
+ console.log('NOT IMPLEMENTED ', { username });
10
+ });
package/lib/dxp.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/dxp.js ADDED
@@ -0,0 +1,21 @@
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
+ const commander_1 = __importDefault(require("commander"));
7
+ const auth_1 = __importDefault(require("./auth"));
8
+ const td_1 = __importDefault(require("./td"));
9
+ const program = new commander_1.default.Command();
10
+ const packageJson = require('../package.json');
11
+ const version = packageJson.version;
12
+ program
13
+ .name('dxp')
14
+ .version(version)
15
+ .description('dxp commands')
16
+ .addCommand(auth_1.default)
17
+ .addCommand(td_1.default)
18
+ .action(() => {
19
+ program.help();
20
+ })
21
+ .parse(process.argv);
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ declare const _default: Command;
3
+ export default _default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const commander_1 = require("commander");
13
+ exports.default = new commander_1.Command()
14
+ .name('deploy')
15
+ .argument('<source>', 'template location')
16
+ .argument('<destination>', 'asset id to deploy too')
17
+ .action((source, destination) => __awaiter(void 0, void 0, void 0, function* () {
18
+ console.log('hello world - ', source, destination);
19
+ }));
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ declare const authCommand: Command;
3
+ export default authCommand;
@@ -0,0 +1,12 @@
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
+ const commander_1 = require("commander");
7
+ const deploy_1 = __importDefault(require("./deploy"));
8
+ const authCommand = new commander_1.Command('td');
9
+ authCommand
10
+ .description('Template deployment commands')
11
+ .addCommand(deploy_1.default);
12
+ exports.default = authCommand;
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@squiz/dxp-cli-next",
3
+ "version": "0.0.0-development",
4
+ "files": [
5
+ "!lib/__tests__/**/*",
6
+ "lib/**/*",
7
+ "bin/**/*"
8
+ ],
9
+ "bin": {
10
+ "dxp": "./bin/dxp.js"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "clean": "rm -rf ./lib/",
15
+ "cm": "cz",
16
+ "coverage": "codecov",
17
+ "lint": "eslint ./src/ --fix",
18
+ "prepare": "husky install",
19
+ "semantic-release": "semantic-release",
20
+ "test:watch": "jest --watch",
21
+ "test": "jest --coverage",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "engines": {
25
+ "node": ">=12.0"
26
+ },
27
+ "keywords": [
28
+ "cli",
29
+ "template",
30
+ "typescript",
31
+ "vscode",
32
+ "jest",
33
+ "husky",
34
+ "commitizen",
35
+ "semantic-release",
36
+ "codecov"
37
+ ],
38
+ "dependencies": {
39
+ "commander": "^9.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^27.4.0",
43
+ "@types/node": "^17.0.14",
44
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
45
+ "@typescript-eslint/parser": "^5.10.2",
46
+ "chalk": "^4.1.2",
47
+ "codecov": "^3.8.3",
48
+ "commitizen": "^4.2.4",
49
+ "cz-conventional-changelog": "^3.3.0",
50
+ "eslint": "^8.8.0",
51
+ "eslint-config-prettier": "^8.3.0",
52
+ "eslint-plugin-node": "^11.1.0",
53
+ "eslint-plugin-prettier": "^4.0.0",
54
+ "execa": "^5.1.1",
55
+ "husky": "^7.0.4",
56
+ "jest": "^27.4.7",
57
+ "lint-staged": "^12.3.3",
58
+ "prettier": "^2.5.1",
59
+ "semantic-release": "^19.0.2",
60
+ "ts-jest": "^27.1.3",
61
+ "ts-node": "^10.4.0",
62
+ "typescript": "^4.5.5"
63
+ },
64
+ "config": {
65
+ "commitizen": {
66
+ "path": "./node_modules/cz-conventional-changelog"
67
+ }
68
+ },
69
+ "lint-staged": {
70
+ "*.ts": "eslint --cache --cache-location .eslintcache --fix"
71
+ },
72
+ "release": {
73
+ "branches": [
74
+ "main"
75
+ ]
76
+ }
77
+ }