@40q/40q-cli 1.0.17 → 1.0.18
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 +2 -1
- package/dist/src/commands/Codegen/Codegen.command.js +29 -7
- package/dist/src/commands/Codegen/Generators/FetchComponents.js +5 -5
- package/dist/src/commands/Codegen/Generators/GenerateBlock.js +11 -5
- package/dist/src/utils/paths.js +3 -3
- package/dist/src/utils/utils.js +7 -2
- package/package.json +1 -1
- package/templates/blocks/default/tsx.txt +2 -2
- package/dist/165.index.js +0 -1
- package/dist/216.index.js +0 -1
- package/dist/284.index.js +0 -1
- package/dist/350.index.js +0 -1
- package/dist/522.index.js +0 -1
- package/dist/62.index.js +0 -2
- package/dist/62.index.js.LICENSE.txt +0 -9
- package/dist/758.index.js +0 -1
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/resources/scripts/editor/blocks/default/default.block.js +0 -39
- package/dist/resources/scripts/editor/blocks/hello-today/hello-today.block.js +0 -39
- package/dist/resources/scripts/editor/blocks/here-we-go-again/here-we-go-again.block.js +0 -39
- package/dist/resources/scripts/editor/blocks/section-header/section-header.block.js +0 -39
- package/dist/resources/scripts/editor/blocks/section-header.js +0 -39
- package/dist/src/commands/Codegen/Generator.factory.js +0 -11
- package/dist/src/commands/Codegen/Generator.js +0 -3
- package/dist/src/commands/Codegen/Generators/BaseGeneratorOptions.js +0 -4
- package/dist/src/commands/Codegen/Generators/GeneratorStrategy.factory.js +0 -11
- package/dist/src/commands/Codegen/Generators/GeneratorStrategy.js +0 -2
- package/dist/src/commands/Codegen/Generators/strategies/BlockGenerator.strategy.js +0 -88
- package/dist/src/commands/Codegen/Prompts/PromptSrategy.js +0 -5
- package/dist/src/commands/Codegen/Prompts/PromptStrategy.factory.js +0 -11
- package/dist/src/commands/Codegen/Prompts/PromptStrategy.js +0 -2
- package/dist/src/commands/Codegen/Prompts/strategies/BlockPrompt.strategy.js +0 -43
- package/dist/src/commands/Codegen/StrategyFactory.js +0 -63
- package/dist/src/commands/Setup.command.js +0 -53
package/dist/758.index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";exports.id=758,exports.ids=[758],exports.modules={10758:(s,e,r)=>{r.r(e)}};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
3
|
-
* CJS and ESM environments.
|
4
|
-
*
|
5
|
-
* @license
|
6
|
-
* Copyright (c) 2016, Contributors
|
7
|
-
* SPDX-License-Identifier: ISC
|
8
|
-
*/
|
9
|
-
|
10
|
-
/**
|
11
|
-
* @license
|
12
|
-
* Copyright (c) 2016, Contributors
|
13
|
-
* SPDX-License-Identifier: ISC
|
14
|
-
*/
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
-
const i18n_1 = require("@wordpress/i18n");
|
5
|
-
const components_1 = require("@wordpress/components");
|
6
|
-
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
-
/* Block name */
|
8
|
-
exports.name = "by40q/default";
|
9
|
-
/* Block title */
|
10
|
-
exports.title = (0, i18n_1.__)("Default", "40q");
|
11
|
-
/* Block category */
|
12
|
-
exports.category = "text";
|
13
|
-
/* Block attributes */
|
14
|
-
exports.attributes = {
|
15
|
-
title: {
|
16
|
-
type: "string",
|
17
|
-
default: "40Q",
|
18
|
-
},
|
19
|
-
};
|
20
|
-
/* Block edit */
|
21
|
-
const edit = ({ attributes, setAttributes }) => {
|
22
|
-
const { title } = attributes;
|
23
|
-
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
-
return (<>
|
25
|
-
<block_editor_1.InspectorControls>
|
26
|
-
<components_1.PanelBody title={(0, i18n_1.__)("Default Settings")} initialOpen></components_1.PanelBody>
|
27
|
-
</block_editor_1.InspectorControls>
|
28
|
-
|
29
|
-
<div {...blockProps}>
|
30
|
-
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
-
</div>
|
32
|
-
</>);
|
33
|
-
};
|
34
|
-
exports.edit = edit;
|
35
|
-
/* Block save */
|
36
|
-
const save = () => <></>;
|
37
|
-
exports.save = save;
|
38
|
-
/* Block styles */
|
39
|
-
exports.styles = [];
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
-
const i18n_1 = require("@wordpress/i18n");
|
5
|
-
const components_1 = require("@wordpress/components");
|
6
|
-
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
-
/* Block name */
|
8
|
-
exports.name = "by40q/hello-today";
|
9
|
-
/* Block title */
|
10
|
-
exports.title = (0, i18n_1.__)("Hello Today", "40q");
|
11
|
-
/* Block category */
|
12
|
-
exports.category = "text";
|
13
|
-
/* Block attributes */
|
14
|
-
exports.attributes = {
|
15
|
-
title: {
|
16
|
-
type: "string",
|
17
|
-
default: "40Q",
|
18
|
-
},
|
19
|
-
};
|
20
|
-
/* Block edit */
|
21
|
-
const edit = ({ attributes, setAttributes }) => {
|
22
|
-
const { title } = attributes;
|
23
|
-
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
-
return (<>
|
25
|
-
<block_editor_1.InspectorControls>
|
26
|
-
<components_1.PanelBody title={(0, i18n_1.__)("Hello Today Settings")} initialOpen></components_1.PanelBody>
|
27
|
-
</block_editor_1.InspectorControls>
|
28
|
-
|
29
|
-
<div {...blockProps}>
|
30
|
-
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
-
</div>
|
32
|
-
</>);
|
33
|
-
};
|
34
|
-
exports.edit = edit;
|
35
|
-
/* Block save */
|
36
|
-
const save = () => <></>;
|
37
|
-
exports.save = save;
|
38
|
-
/* Block styles */
|
39
|
-
exports.styles = [];
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
-
const i18n_1 = require("@wordpress/i18n");
|
5
|
-
const components_1 = require("@wordpress/components");
|
6
|
-
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
-
/* Block name */
|
8
|
-
exports.name = "by40q/here-we-go-again";
|
9
|
-
/* Block title */
|
10
|
-
exports.title = (0, i18n_1.__)("Here We Go Again", "40q");
|
11
|
-
/* Block category */
|
12
|
-
exports.category = "text";
|
13
|
-
/* Block attributes */
|
14
|
-
exports.attributes = {
|
15
|
-
title: {
|
16
|
-
type: "string",
|
17
|
-
default: "40Q",
|
18
|
-
},
|
19
|
-
};
|
20
|
-
/* Block edit */
|
21
|
-
const edit = ({ attributes, setAttributes }) => {
|
22
|
-
const { title } = attributes;
|
23
|
-
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
-
return (<>
|
25
|
-
<block_editor_1.InspectorControls>
|
26
|
-
<components_1.PanelBody title={(0, i18n_1.__)("Here We Go Again Settings")} initialOpen></components_1.PanelBody>
|
27
|
-
</block_editor_1.InspectorControls>
|
28
|
-
|
29
|
-
<div {...blockProps}>
|
30
|
-
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
-
</div>
|
32
|
-
</>);
|
33
|
-
};
|
34
|
-
exports.edit = edit;
|
35
|
-
/* Block save */
|
36
|
-
const save = () => <></>;
|
37
|
-
exports.save = save;
|
38
|
-
/* Block styles */
|
39
|
-
exports.styles = [];
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
-
const i18n_1 = require("@wordpress/i18n");
|
5
|
-
const components_1 = require("@wordpress/components");
|
6
|
-
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
-
/* Block name */
|
8
|
-
exports.name = "by40q/section-header";
|
9
|
-
/* Block title */
|
10
|
-
exports.title = (0, i18n_1.__)("Section Header", "40q");
|
11
|
-
/* Block category */
|
12
|
-
exports.category = "text";
|
13
|
-
/* Block attributes */
|
14
|
-
exports.attributes = {
|
15
|
-
title: {
|
16
|
-
type: "string",
|
17
|
-
default: "40Q",
|
18
|
-
},
|
19
|
-
};
|
20
|
-
/* Block edit */
|
21
|
-
const edit = ({ attributes, setAttributes }) => {
|
22
|
-
const { title } = attributes;
|
23
|
-
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
-
return (<>
|
25
|
-
<block_editor_1.InspectorControls>
|
26
|
-
<components_1.PanelBody title={(0, i18n_1.__)("Section Header Settings")} initialOpen></components_1.PanelBody>
|
27
|
-
</block_editor_1.InspectorControls>
|
28
|
-
|
29
|
-
<div {...blockProps}>
|
30
|
-
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
-
</div>
|
32
|
-
</>);
|
33
|
-
};
|
34
|
-
exports.edit = edit;
|
35
|
-
/* Block save */
|
36
|
-
const save = () => <></>;
|
37
|
-
exports.save = save;
|
38
|
-
/* Block styles */
|
39
|
-
exports.styles = [];
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
-
const i18n_1 = require("@wordpress/i18n");
|
5
|
-
const components_1 = require("@wordpress/components");
|
6
|
-
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
-
/* Block name */
|
8
|
-
exports.name = "by40q/section-header";
|
9
|
-
/* Block title */
|
10
|
-
exports.title = (0, i18n_1.__)("Section Header", "40q");
|
11
|
-
/* Block category */
|
12
|
-
exports.category = "text";
|
13
|
-
/* Block attributes */
|
14
|
-
exports.attributes = {
|
15
|
-
title: {
|
16
|
-
type: "string",
|
17
|
-
default: "40Q",
|
18
|
-
},
|
19
|
-
};
|
20
|
-
/* Block edit */
|
21
|
-
const edit = ({ attributes, setAttributes }) => {
|
22
|
-
const { title } = attributes;
|
23
|
-
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
-
return (<>
|
25
|
-
<block_editor_1.InspectorControls>
|
26
|
-
<components_1.PanelBody title={(0, i18n_1.__)("Section Header Settings")} initialOpen></components_1.PanelBody>
|
27
|
-
</block_editor_1.InspectorControls>
|
28
|
-
|
29
|
-
<div {...blockProps}>
|
30
|
-
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
-
</div>
|
32
|
-
</>);
|
33
|
-
};
|
34
|
-
exports.edit = edit;
|
35
|
-
/* Block save */
|
36
|
-
const save = ({ attributes }) => <></>;
|
37
|
-
exports.save = save;
|
38
|
-
/* Block styles */
|
39
|
-
exports.styles = [];
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
class GeneratorFactory {
|
3
|
-
// private generators: Record<string, Generator>;
|
4
|
-
constructor(directory) {
|
5
|
-
this.directory = directory;
|
6
|
-
// this.generators = this.discoverGenerators();
|
7
|
-
}
|
8
|
-
discoverGenerators() {
|
9
|
-
// this.directory contains a bunch of files. Each file is called something.generator.ts. something is the key of the generator
|
10
|
-
}
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GeneratorStrategyFactory = void 0;
|
4
|
-
const StrategyFactory_1 = require("../StrategyFactory");
|
5
|
-
class GeneratorStrategyFactory extends StrategyFactory_1.StrategyFactory {
|
6
|
-
constructor() {
|
7
|
-
super(...arguments);
|
8
|
-
this.pattern = 'Generator.strategy';
|
9
|
-
}
|
10
|
-
}
|
11
|
-
exports.GeneratorStrategyFactory = GeneratorStrategyFactory;
|
@@ -1,88 +0,0 @@
|
|
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 (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.BlockGenerator = void 0;
|
30
|
-
const fs = __importStar(require("fs"));
|
31
|
-
const path_1 = __importDefault(require("path"));
|
32
|
-
const child_process_1 = require("child_process");
|
33
|
-
const cliRoot_1 = require("../../../../lib/cliRoot");
|
34
|
-
class BlockGenerator {
|
35
|
-
constructor(options) {
|
36
|
-
this.template = '';
|
37
|
-
this.name = '';
|
38
|
-
this.title = '';
|
39
|
-
this.camelCaseName = '';
|
40
|
-
console.log(options);
|
41
|
-
this.template = options.template === '' ? 'default' : options.template;
|
42
|
-
this.name = options.name || 'default';
|
43
|
-
this.camelCaseName = this.toCamelCase(this.name);
|
44
|
-
this.title = this.parseName(this.name);
|
45
|
-
}
|
46
|
-
run() {
|
47
|
-
this.createBlockFolder();
|
48
|
-
this.createBlockFiles();
|
49
|
-
}
|
50
|
-
createBlockFolder() {
|
51
|
-
(0, child_process_1.execSync)(`mkdir -p resources/scripts/editor/blocks/${this.name}`);
|
52
|
-
}
|
53
|
-
createBlockFiles() {
|
54
|
-
var _a, _b;
|
55
|
-
fs.writeFileSync(path_1.default.join(process.cwd(), `resources/scripts/editor/blocks/${this.name}/${this.name}.block.tsx`), this.getTemplate('tsx')
|
56
|
-
.replace(/{{name}}/g, (_a = this.name) !== null && _a !== void 0 ? _a : '')
|
57
|
-
.replace(/{{title}}/g, this.title));
|
58
|
-
fs.writeFileSync(path_1.default.join(process.cwd(), `resources/views/blocks/${this.name}.blade.php`), this.getTemplate('blade'));
|
59
|
-
fs.writeFileSync(path_1.default.join(process.cwd(), `app/Blocks/${this.camelCaseName}.php`), this.getTemplate('php')
|
60
|
-
.replace(/{{name}}/g, (_b = this.name) !== null && _b !== void 0 ? _b : '')
|
61
|
-
.replace(/{{camelCaseName}}/g, this.camelCaseName));
|
62
|
-
}
|
63
|
-
parseName(name) {
|
64
|
-
return name
|
65
|
-
.split('-')
|
66
|
-
.map((word) => {
|
67
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
68
|
-
})
|
69
|
-
.join(' ');
|
70
|
-
}
|
71
|
-
toCamelCase(name) {
|
72
|
-
var _a;
|
73
|
-
return ((_a = name.split('-').reduce((acc, word) => {
|
74
|
-
return acc + word.charAt(0).toUpperCase() + word.slice(1);
|
75
|
-
}, '')) !== null && _a !== void 0 ? _a : '');
|
76
|
-
}
|
77
|
-
getTemplate(name) {
|
78
|
-
try {
|
79
|
-
const cliRoot = (0, cliRoot_1.findCliRoot)(__dirname);
|
80
|
-
const templateFolder = `templates/blocks/${this.template}`;
|
81
|
-
return fs.readFileSync(path_1.default.join(cliRoot, `${templateFolder}/${name}.txt`), 'utf8');
|
82
|
-
}
|
83
|
-
catch (e) {
|
84
|
-
return '';
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
exports.BlockGenerator = BlockGenerator;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PromptStrategyFactory = void 0;
|
4
|
-
const StrategyFactory_1 = require("../StrategyFactory");
|
5
|
-
class PromptStrategyFactory extends StrategyFactory_1.StrategyFactory {
|
6
|
-
constructor() {
|
7
|
-
super(...arguments);
|
8
|
-
this.pattern = 'Prompt.strategy';
|
9
|
-
}
|
10
|
-
}
|
11
|
-
exports.PromptStrategyFactory = PromptStrategyFactory;
|
@@ -1,43 +0,0 @@
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
16
|
-
const config_1 = require("@/config");
|
17
|
-
class BlockPromptStrategy {
|
18
|
-
prompt() {
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
20
|
-
const templateAnswer = yield inquirer_1.default.prompt([
|
21
|
-
{
|
22
|
-
type: 'list',
|
23
|
-
name: 'template',
|
24
|
-
message: 'Please select a template:',
|
25
|
-
choices: config_1.config.templateChoices.block,
|
26
|
-
default: '',
|
27
|
-
}
|
28
|
-
]);
|
29
|
-
const template = (templateAnswer === null || templateAnswer === void 0 ? void 0 : templateAnswer.template) || '';
|
30
|
-
const answers = yield inquirer_1.default.prompt([
|
31
|
-
{
|
32
|
-
type: 'input',
|
33
|
-
name: 'name',
|
34
|
-
message: 'Please enter a name for the block:',
|
35
|
-
default: template || 'block-name',
|
36
|
-
},
|
37
|
-
]);
|
38
|
-
const name = (answers === null || answers === void 0 ? void 0 : answers.name) || '';
|
39
|
-
return { name, template };
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
exports.default = BlockPromptStrategy;
|
@@ -1,63 +0,0 @@
|
|
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 (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
-
});
|
33
|
-
};
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
-
};
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
-
exports.StrategyFactory = void 0;
|
39
|
-
const path_1 = __importDefault(require("path"));
|
40
|
-
class StrategyFactory {
|
41
|
-
constructor() {
|
42
|
-
this.directory = 'strategies';
|
43
|
-
}
|
44
|
-
getStrategyFileName(type) {
|
45
|
-
const camelCaseType = type.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
46
|
-
return `${camelCaseType}${this.pattern}.strategy.ts`;
|
47
|
-
}
|
48
|
-
getStrategy(type) {
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
50
|
-
const strategyFileName = this.getStrategyFileName(type);
|
51
|
-
const strategyFilePath = path_1.default.join(__dirname, this.directory, strategyFileName);
|
52
|
-
try {
|
53
|
-
const strategyModule = yield Promise.resolve(`${strategyFilePath}`).then(s => __importStar(require(s)));
|
54
|
-
return new strategyModule.default();
|
55
|
-
}
|
56
|
-
catch (error) {
|
57
|
-
console.error(`Failed to import strategy '${type}':`, error);
|
58
|
-
return null;
|
59
|
-
}
|
60
|
-
});
|
61
|
-
}
|
62
|
-
}
|
63
|
-
exports.StrategyFactory = StrategyFactory;
|
@@ -1,53 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SetupCommand = void 0;
|
4
|
-
const child_process_1 = require("child_process");
|
5
|
-
const eslintrc = `
|
6
|
-
{
|
7
|
-
"extends": ["@40q/eslint-config"]
|
8
|
-
}
|
9
|
-
`;
|
10
|
-
const huskyrc = `
|
11
|
-
{
|
12
|
-
"hooks": {
|
13
|
-
"pre-commit": "lint-staged"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
`;
|
17
|
-
const lintstagedrc = `
|
18
|
-
{
|
19
|
-
"*.{js,jsx,ts,tsx}": ["eslint --fix"]
|
20
|
-
}
|
21
|
-
`;
|
22
|
-
class SetupCommand {
|
23
|
-
static builder(yargs) {
|
24
|
-
yargs.positional('tool', {
|
25
|
-
describe: 'Name of the tool to setup',
|
26
|
-
type: 'string',
|
27
|
-
});
|
28
|
-
}
|
29
|
-
static handler(argv) {
|
30
|
-
SetupCommand.setupTool(argv.tool);
|
31
|
-
}
|
32
|
-
static setupTool(tool) {
|
33
|
-
switch (tool) {
|
34
|
-
case 'eslint':
|
35
|
-
this.setupEslint();
|
36
|
-
break;
|
37
|
-
default:
|
38
|
-
console.error(`Unknown tool: ${tool}. Please specify a supported tool.`);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
static setupEslint() {
|
42
|
-
console.log('Installing dependencies...');
|
43
|
-
(0, child_process_1.execSync)('yarn add --dev eslint @40q/eslint-config husky lint-staged');
|
44
|
-
console.log('Creating .eslintrc.json...');
|
45
|
-
(0, child_process_1.execSync)(`echo '${eslintrc}' > .eslintrc.json`);
|
46
|
-
console.log('Creating .huskyrc.json...');
|
47
|
-
(0, child_process_1.execSync)(`echo '${huskyrc}' > .huskyrc.json`);
|
48
|
-
console.log('Creating .lintstagedrc.json...');
|
49
|
-
(0, child_process_1.execSync)(`echo '${lintstagedrc}' > .lintstagedrc.json`);
|
50
|
-
console.log('Done!');
|
51
|
-
}
|
52
|
-
}
|
53
|
-
exports.SetupCommand = SetupCommand;
|