diff --git a/commitlint.config.js b/commitlint.config.js index 3f5e287..fa584fb 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -export default { extends: ['@commitlint/config-conventional'] }; +export default { extends: ["@commitlint/config-conventional"] }; diff --git a/eslint.config.js b/eslint.config.js index d477281..bd67bc6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,9 +1,11 @@ import globals from "globals"; import tseslint from "typescript-eslint"; +import eslintPrettier from "eslint-plugin-prettier/recommended"; export default [ {languageOptions: { globals: globals.browser }}, ...tseslint.configs.recommended, + eslintPrettier, { ignores: [ "**/.gitignore", diff --git a/generators/app/index.js b/generators/app/index.js index 7088ee8..7f19def 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -44,9 +44,9 @@ export default class LibraryGenerator extends Generator { message: "Include fastify plugin?", name: "fastifyPlugin", type: "confirm", - } + }, ]); - }; + } async writing() { await this.fs.copyTplAsync( @@ -57,18 +57,18 @@ export default class LibraryGenerator extends Generator { ...this.options, }, {}, - { - globOptions: { + { + globOptions: { dot: true, - } + }, }, ); if (this.props.fastifyPlugin) { await this.composeWith( - { - Generator: FastifyPluginGenerator, - path: "../fastify-plugin/index.js" + { + Generator: FastifyPluginGenerator, + path: "../fastify-plugin/index.js", }, { authorEmail: this.props.authorEmail, @@ -80,8 +80,8 @@ export default class LibraryGenerator extends Generator { installationType: "library", scope: this.props.scope, version: this.props.version, - } + }, ); } } -}; +} diff --git a/generators/app/templates/.github/workflows/shipjs-trigger.yml b/generators/app/templates/.github/workflows/shipjs-trigger.yml index eb1c225..aaefcc2 100644 --- a/generators/app/templates/.github/workflows/shipjs-trigger.yml +++ b/generators/app/templates/.github/workflows/shipjs-trigger.yml @@ -19,15 +19,12 @@ jobs: with: node-version: 20 registry-url: "https://registry.npmjs.org" - - name: Install pnpm + - name: Setup pnpm and install dependencies uses: pnpm/action-setup@v4 with: run_install: | - - version: 8 - recursive: true args: [--frozen-lockfile, --strict-peer-dependencies] - - run: - pnpm -r install - run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" diff --git a/generators/app/templates/.github/workflows/test.yml b/generators/app/templates/.github/workflows/test.yml index 8b62c00..9c304e1 100644 --- a/generators/app/templates/.github/workflows/test.yml +++ b/generators/app/templates/.github/workflows/test.yml @@ -10,23 +10,19 @@ jobs: matrix: node-version: [20, 21] steps: - - uses: actions/checkout@v4 - name: Use node ${{ matrix.node-version }} - - - uses: actions/setup-node@v4 + - name: Checkout + uses: actions/checkout@v4 + - name: Use node ${{ matrix.node-version }} + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm + - name: Setup pnpm and install dependencies + uses: pnpm/action-setup@v4 with: - version: 8 - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - + run_install: | + - recursive: true + args: [--frozen-lockfile, --strict-peer-dependencies] - name: Build packages run: pnpm build - - name: Run tests run: pnpm test diff --git a/generators/fastify-plugin/index.js b/generators/fastify-plugin/index.js index 700b7fb..7687aba 100644 --- a/generators/fastify-plugin/index.js +++ b/generators/fastify-plugin/index.js @@ -19,7 +19,9 @@ export default class FastifyPluginGenerator extends Generator { type: "input", }, { - default: this.options.baseName? `${this.options.baseName}-fastify`: "fastify", + default: this.options.baseName + ? `${this.options.baseName}-fastify` + : "fastify", message: "Fastify plugin name", name: "name", type: "input", @@ -46,7 +48,7 @@ export default class FastifyPluginGenerator extends Generator { } else { this.props.authorName = this.options.authorName; } - + if (!this.options.authorEmail) { prompts.push({ message: "Author email", @@ -75,15 +77,15 @@ export default class FastifyPluginGenerator extends Generator { choices: [ { name: "Generate this fastify plugin in library monorepo", - value: "library" + value: "library", }, { name: "Generate this fastify plugin in app monorepo", - value: "app" + value: "app", }, { name: "Standalone", - value: "standalone" + value: "standalone", }, ], }); @@ -99,14 +101,21 @@ export default class FastifyPluginGenerator extends Generator { type: "input", }); - this.props["baseName"] = baseName; + this.props["baseName"] = baseName; } else { this.props["baseName"] = this.options.baseName; } if (!this.options.destinationPath) { + const defaultPath = + this.props.installationType === "library" + ? "./packages/fastify" + : this.props.installationType === "app" + ? "./libs/fastify" + : `./${this.props.name}`; + const { destinationPath } = await this.prompt({ - default: `${this.props.name}`, + default: defaultPath, message: "Destination path", name: "destinationPath", type: "input", @@ -118,53 +127,53 @@ export default class FastifyPluginGenerator extends Generator { } const { description } = await this.prompt({ - default: this.options.description + default: this.options.description ? this.options.description : generateDescription( this.props.installationType, this.options.name || this.props.name, - this.props.baseName - ), + this.props.baseName, + ), message: "Enter fastify plugin description", name: "description", - type: "input" + type: "input", }); - + this.props["description"] = description; - this.props["displayName"] = - [this.props.scope, this.props.name] + this.props["displayName"] = [this.props.scope, this.props.name] .join("-") .split("-") - .map(token => token.charAt(0).toUpperCase() + token.slice(1)) + .map((token) => token.charAt(0).toUpperCase() + token.slice(1)) .join(""); - }; + } async writing() { await this.fs.copyTplAsync( this.templatePath(), - this.destinationPath(path.join(this.options.baseName || "", this.props.destinationPath )), + this.destinationPath( + path.join(this.options.baseName || "", this.props.destinationPath), + ), { ...this.props, ...this.options, }, {}, { - globOptions: { + globOptions: { dot: true, - } + }, }, ); } -}; +} const capitalize = (word) => { return word ? word.charAt(0).toUpperCase() + word.slice(1) : word; }; const generateDescription = (installationType, name, baseName) => { - let description, - capitalizedName; + let description, capitalizedName; switch (installationType) { case "library": @@ -180,4 +189,4 @@ const generateDescription = (installationType, name, baseName) => { } return description; -} +};