-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add nx plugin for generating new packages
It looks like the plugin needs to be in CommonJS as all `nx` plugins need to be in CommonJS: https://www.github.com/nrwl/nx/issues/15682 Useful docs: https://nx.dev/extending-nx/recipes/local-generators Related to #83
- Loading branch information
1 parent
a4e4d5c
commit 9232b36
Showing
19 changed files
with
1,770 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "@serieslist/eslint-config-base", | ||
"root": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"@serieslist/prettier-config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @serieslist/nx-plugin | ||
|
||
A plugin for `nx` defining some useful generators. | ||
|
||
Useful docs: https://nx.dev/extending-nx/recipes/local-generators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"generators": { | ||
"package": { | ||
"factory": "./src/generators/package/generator", | ||
"schema": "./src/generators/package/schema.json", | ||
"description": "package generator" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@serieslist/nx-plugin", | ||
"version": "0.0.1", | ||
"type": "commonjs", | ||
"main": "./src/index.ts", | ||
"typings": "./src/index.ts", | ||
"generators": "./generators.json", | ||
"dependencies": { | ||
"@nx/devkit": "17.2.8", | ||
"tslib": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@serieslist/eslint-config-base": "workspace:*", | ||
"@serieslist/prettier-config": "workspace:*", | ||
"@serieslist/typescript-config-base": "workspace:*", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/nx-plugin/src/generators/package/files/.eslintrc.json.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "@serieslist/eslint-config-base", | ||
"root": true | ||
} |
1 change: 1 addition & 0 deletions
1
packages/nx-plugin/src/generators/package/files/.prettierrc.json.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"@serieslist/prettier-config" |
21 changes: 21 additions & 0 deletions
21
packages/nx-plugin/src/generators/package/files/package.json.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@serieslist/<?= name %>", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./src/index.ts", | ||
"types": "./src/index.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"lint": "eslint src", | ||
"tsc": "tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"@serieslist/eslint-config-base": "workspace:*", | ||
"@serieslist/prettier-config": "workspace:*", | ||
"@serieslist/typescript-config-base": "workspace:*", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/nx-plugin/src/generators/package/files/src/index.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const variable = "<%= name %>"; |
3 changes: 3 additions & 0 deletions
3
packages/nx-plugin/src/generators/package/files/tsconfig.json.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@serieslist/typescript-config-base" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { join } from 'path' | ||
|
||
import { formatFiles, generateFiles, type Tree } from '@nx/devkit' | ||
|
||
import { type PackageGeneratorSchema } from './schema' | ||
|
||
export async function packageGenerator( | ||
tree: Tree, | ||
options: PackageGeneratorSchema, | ||
) { | ||
const projectRoot = `packages/${options.name}` | ||
generateFiles(tree, join(__dirname, 'files'), projectRoot, options) | ||
await formatFiles(tree) | ||
} | ||
|
||
export default packageGenerator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type PackageGeneratorSchema = { | ||
name: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"$id": "Package", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "@serieslist/typescript-config-base", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"] | ||
} |
Oops, something went wrong.