@react-ddd/cli
Advanced tools
| // istanbul ignore file | ||
| export { default } from './use{{name.pascal}}'; | ||
| export type { {{name.pascal}} } from './use{{name.pascal}}'; |
| import test from 'jest-gwt'; | ||
| import { render } from '@testing-library/react-hooks'; | ||
| import '@testing-library/jest-dom'; | ||
| import use{{name.pascal}} from './{{name.pascal}}'; | ||
| import type { {{name.pascal}} } from './use{{name.pascal}}'; | ||
| describe('hooks > {{name}}', () => { | ||
| test('renders', { | ||
| given: {}, | ||
| when: { | ||
| using_hook, | ||
| }, | ||
| then: { | ||
| }, | ||
| }); | ||
| }); | ||
| type Context = { | ||
| result: {{name.pascal}}, | ||
| }; | ||
| function using_hook(this: Context) { | ||
| const { result } = render(() => { | ||
| use{{name.pascal}}(); | ||
| }); | ||
| } |
| export type {{name.pascal}} = {}; | ||
| export default (): {{name.pascal}} => { | ||
| }; |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.builder = exports.alias = exports.description = exports.command = void 0; | ||
| const path_1 = __importDefault(require("path")); | ||
| const generator_1 = __importDefault(require("#helpers/generator")); | ||
| const loadConfig_1 = __importDefault(require("#helpers/loadConfig")); | ||
| const caseify_1 = __importDefault(require("#helpers/caseify")); | ||
| const template = path_1.default.join(__dirname, 'hook_template'); | ||
| const options = { | ||
| name: { | ||
| describe: 'What is the name of the new hook?', | ||
| type: 'input', | ||
| validate: (x) => (x.trim() | ||
| ? true | ||
| : 'Must provide a name'), | ||
| }, | ||
| interactive: { | ||
| default: true, | ||
| }, | ||
| }; | ||
| exports.command = ['hook', 'h']; | ||
| exports.description = 'Generate a hook'; | ||
| exports.alias = 'c'; | ||
| const builder = (argv) => argv | ||
| .interactive(options) | ||
| .then(async (args) => { | ||
| const config = await (0, loadConfig_1.default)(args); | ||
| (0, generator_1.default)(template, { | ||
| config, | ||
| args: { | ||
| ...args, | ||
| name: (0, caseify_1.default)(args.name), | ||
| }, | ||
| }); | ||
| }); | ||
| exports.builder = builder; |
| module.exports = { | ||
| extends: [ | ||
| '@react-ddd', | ||
| '@react-ddd{{#unless react}}/eslint-config/typescript{{/unless}}', | ||
| ], | ||
@@ -5,0 +5,0 @@ parserOptions: { |
@@ -5,9 +5,9 @@ module.exports = { | ||
| roots: [ | ||
| '{{ config.sourceRoot }}', | ||
| '{{ sourceRoot }}', | ||
| ], | ||
| collectCoverageFrom: [ | ||
| '{{ config.sourceRoot }}/**/*.ts', | ||
| '{{ config.sourceRoot }}/**/*.tsx', | ||
| '{{ sourceRoot }}/**/*.ts'{{#if react}}, | ||
| '{{ sourceRoot }}/**/*.tsx',{{/if}} | ||
| ], | ||
| coverageDirectory: './.build/coverage', | ||
| }; |
@@ -7,4 +7,4 @@ { | ||
| "include": [ | ||
| "**/*.ts", | ||
| "**/*.tsx", | ||
| "**/*.ts"{{#if react}}, | ||
| "**/*.tsx",{{/if}} | ||
| "*.js", | ||
@@ -11,0 +11,0 @@ ".eslintrc.js", |
@@ -11,4 +11,4 @@ { | ||
| "noImplicitAny": true, | ||
| "incremental": true, | ||
| "jsx": "react", | ||
| "incremental": true{{#if react}}, | ||
| "jsx": "react"{{#if nextjs}}, | ||
| "baseUrl": ".", | ||
@@ -28,3 +28,3 @@ "paths": { | ||
| ] | ||
| } | ||
| }{{/if}}{{/if}} | ||
| }, | ||
@@ -31,0 +31,0 @@ "exclude": [ |
+20
-11
@@ -20,7 +20,7 @@ "use strict"; | ||
| '@react-ddd/eslint-config', | ||
| '@testing-library/jest-dom', | ||
| '@testing-library/react', | ||
| ['@testing-library/jest-dom', (args) => args.react], | ||
| ['@testing-library/react', (args) => args.react], | ||
| '@types/jest', | ||
| '@types/react', | ||
| '@types/react-dom', | ||
| ['@types/react', (args) => args.react], | ||
| ['@types/react-dom', (args) => args.react], | ||
| 'jest', | ||
@@ -32,8 +32,8 @@ 'jest-gwt', | ||
| const dependencies = [ | ||
| '@react-shanties/core', | ||
| '@reduxjs/toolkit', | ||
| 'react', | ||
| 'react-dom', | ||
| 'react-redux', | ||
| 'redux', | ||
| ['@react-shanties/core', (args) => args.react], | ||
| ['@reduxjs/toolkit', (args) => args.react], | ||
| ['react', (args) => args.react], | ||
| ['react-dom', (args) => args.react], | ||
| ['react-redux', (args) => args.react], | ||
| ['redux', (args) => args.react], | ||
| ['next', (args) => args.nextjs], | ||
@@ -49,2 +49,8 @@ ]; | ||
| }, | ||
| react: { | ||
| type: 'confirm', | ||
| describe: 'Is this a React project?', | ||
| default: true, | ||
| prompt: 'always', | ||
| }, | ||
| nextjs: { | ||
@@ -67,3 +73,6 @@ type: 'confirm', | ||
| (0, generator_1.default)(configTemplate, { | ||
| config, | ||
| config: { | ||
| ...config, | ||
| sourceRoot: '.', | ||
| }, | ||
| args, | ||
@@ -70,0 +79,0 @@ }); |
@@ -20,3 +20,2 @@ "use strict"; | ||
| if (element.isDirectory()) { | ||
| fs_1.default.mkdirSync(outputPath, { recursive: true }); | ||
| createDirectory(templatePath, replacements, templateRoot, projectRoot); | ||
@@ -30,2 +29,3 @@ } | ||
| } | ||
| fs_1.default.mkdirSync(handlebars_1.default.compile(path_1.default.join(projectRoot, relativePath))(replacements), { recursive: true }); | ||
| fs_1.default.writeFileSync(outputPath, template, { encoding: 'utf-8' }); | ||
@@ -32,0 +32,0 @@ } |
+2
-2
| { | ||
| "name": "@react-ddd/cli", | ||
| "version": "0.0.3", | ||
| "version": "0.0.5", | ||
| "description": "Code generation", | ||
@@ -114,2 +114,2 @@ "main": "dist/index.js", | ||
| } | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
58927
5.01%38
11.76%458
11.71%