@robert-brightline/plugin 0.0.1

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.
Files changed (45) hide show
  1. package/README.md +34 -0
  2. package/dist/common/git.d.ts +9 -0
  3. package/dist/common/git.d.ts.map +1 -0
  4. package/dist/common/git.js +44 -0
  5. package/dist/generators/component/component.d.ts +5 -0
  6. package/dist/generators/component/component.d.ts.map +1 -0
  7. package/dist/generators/component/component.js +18 -0
  8. package/dist/generators/component/files/src/index.ts.template +1 -0
  9. package/dist/generators/component/schema.d.ts +3 -0
  10. package/dist/generators/component/schema.json +18 -0
  11. package/dist/generators/project/library/.swcrc.template +28 -0
  12. package/dist/generators/project/library/LICENSE.template +21 -0
  13. package/dist/generators/project/library/README.md.template +37 -0
  14. package/dist/generators/project/library/eslint.config.mjs.template +3 -0
  15. package/dist/generators/project/library/package.json.template +60 -0
  16. package/dist/generators/project/library/src/index.ts.template +3 -0
  17. package/dist/generators/project/library/src/lib/__fileName__.spec.ts.template +7 -0
  18. package/dist/generators/project/library/src/lib/__fileName__.ts.template +3 -0
  19. package/dist/generators/project/library/tsconfig.json.template +13 -0
  20. package/dist/generators/project/library/tsconfig.lib.json.template +24 -0
  21. package/dist/generators/project/library/tsconfig.spec.json.template +26 -0
  22. package/dist/generators/project/library/vite.config.ts.template +20 -0
  23. package/dist/generators/project/library/vitest.config.mts.template +18 -0
  24. package/dist/generators/project/project-options.d.ts +19 -0
  25. package/dist/generators/project/project-options.d.ts.map +1 -0
  26. package/dist/generators/project/project-options.js +44 -0
  27. package/dist/generators/project/project.d.ts +5 -0
  28. package/dist/generators/project/project.d.ts.map +1 -0
  29. package/dist/generators/project/project.js +13 -0
  30. package/dist/generators/project/schema.d.ts +15 -0
  31. package/dist/generators/project/schema.json +39 -0
  32. package/dist/generators/project/update-tsconfig.d.ts +4 -0
  33. package/dist/generators/project/update-tsconfig.d.ts.map +1 -0
  34. package/dist/generators/project/update-tsconfig.js +16 -0
  35. package/dist/generators/resource/files/src/index.ts.template +1 -0
  36. package/dist/generators/resource/resource.d.ts +5 -0
  37. package/dist/generators/resource/resource.d.ts.map +1 -0
  38. package/dist/generators/resource/resource.js +18 -0
  39. package/dist/generators/resource/schema.d.ts +3 -0
  40. package/dist/generators/resource/schema.json +18 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +2 -0
  44. package/generators.json +19 -0
  45. package/package.json +79 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ ![npm version](https://img.shields.io/npm/v/@robert-brightline/plugin)
2
+ ![npm downloads](https://img.shields.io/npm/dm/@robert-brightline/plugin)
3
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/robert-brightline/robert-brightline/ci.yml)
4
+ ![bundle size](https://img.shields.io/bundlephobia/min/@robert-brightline/plugin)
5
+
6
+ <p align="center">
7
+ <img src="./assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
8
+ </p>
9
+
10
+ ## @robert-brightline/plugin
11
+
12
+ Project and resource generators
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @robert-brightline/plugin
18
+ ```
19
+
20
+ ## 💖 Support My Work
21
+
22
+ If you find my open-source contributions or the **@robert-brightline/plugin** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
23
+
24
+ [![CashApp](https://img.shields.io/badge/Sponsor%20me-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](https://cash.app/$puqlib)
25
+
26
+ ---
27
+
28
+ ## 🤝 Connect with Me
29
+
30
+ <p align="left">
31
+ <a href="mailto:robert.brightline+plugin@gmail.com">
32
+ <img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
33
+ </a>
34
+ </p>
@@ -0,0 +1,9 @@
1
+ export declare function gitCurrentUsername(): string;
2
+ export declare function gitRepoUrl(): string;
3
+ export declare function gitRepoOwnerUsername(repositoryUrl: string): string;
4
+ export declare function gitRepoName(repositoryUrl: string): string;
5
+ export declare function githubPage(repoName: string): string;
6
+ export declare function githubPageForDoc(githubPage: string, directory: string): string;
7
+ export declare function gitEmail(): string;
8
+ export declare function suffixEmail(email: string, suffix: string): string;
9
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/common/git.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,WAEjC;AAED,wBAAgB,UAAU,WAEzB;AACD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,UAQzD;AAED,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,UAOhD;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,UAE1C;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAErE;AAED,wBAAgB,QAAQ,WAEvB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAExD"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gitCurrentUsername = gitCurrentUsername;
4
+ exports.gitRepoUrl = gitRepoUrl;
5
+ exports.gitRepoOwnerUsername = gitRepoOwnerUsername;
6
+ exports.gitRepoName = gitRepoName;
7
+ exports.githubPage = githubPage;
8
+ exports.githubPageForDoc = githubPageForDoc;
9
+ exports.gitEmail = gitEmail;
10
+ exports.suffixEmail = suffixEmail;
11
+ const child_process_1 = require("child_process");
12
+ function gitCurrentUsername() {
13
+ return (0, child_process_1.execSync)('git config user.name').toString().trim();
14
+ }
15
+ function gitRepoUrl() {
16
+ return (0, child_process_1.execSync)('git config --get remote.origin.url').toString().trim();
17
+ }
18
+ function gitRepoOwnerUsername(repositoryUrl) {
19
+ const ownerUsername = repositoryUrl.match(/github\.com\/([^/]+)/)?.[1];
20
+ if (ownerUsername === undefined) {
21
+ throw new Error('Owner username could not be determined from remote URL');
22
+ }
23
+ return ownerUsername;
24
+ }
25
+ function gitRepoName(repositoryUrl) {
26
+ const match = repositoryUrl.match(/\/([^\\/]+)\.git$/);
27
+ const repoName = match?.[1];
28
+ if (repoName === undefined) {
29
+ throw new Error('Repository name could not be determined from remote URL');
30
+ }
31
+ return repoName;
32
+ }
33
+ function githubPage(repoName) {
34
+ return `https://${repoName}.github.io`;
35
+ }
36
+ function githubPageForDoc(githubPage, directory) {
37
+ return `${githubPage}/${directory}`;
38
+ }
39
+ function gitEmail() {
40
+ return (0, child_process_1.execSync)('git config user.email').toString().trim();
41
+ }
42
+ function suffixEmail(email, suffix) {
43
+ return email.replace(/(@.+)$/, `+${suffix}$1`);
44
+ }
@@ -0,0 +1,5 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { ComponentGeneratorSchema } from './schema';
3
+ export declare function componentGenerator(tree: Tree, options: ComponentGeneratorSchema): Promise<void>;
4
+ export default componentGenerator;
5
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/generators/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,iBAWlC;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.componentGenerator = componentGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const path = tslib_1.__importStar(require("path"));
7
+ async function componentGenerator(tree, options) {
8
+ const projectRoot = `libs/${options.name}`;
9
+ (0, devkit_1.addProjectConfiguration)(tree, options.name, {
10
+ root: projectRoot,
11
+ projectType: 'library',
12
+ sourceRoot: `${projectRoot}/src`,
13
+ targets: {},
14
+ });
15
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectRoot, options);
16
+ await (0, devkit_1.formatFiles)(tree);
17
+ }
18
+ exports.default = componentGenerator;
@@ -0,0 +1 @@
1
+ const variable = "<%= name %>";
@@ -0,0 +1,3 @@
1
+ export interface ComponentGeneratorSchema {
2
+ name: string;
3
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "Component",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use?"
15
+ }
16
+ },
17
+ "required": ["name"]
18
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2017",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true
12
+ },
13
+ "keepClassNames": true,
14
+ "externalHelpers": true,
15
+ "loose": true
16
+ },
17
+ "module": {
18
+ "type": "es6"
19
+ },
20
+ "sourceMaps": true,
21
+ "exclude": [
22
+ "vite.config.ts",
23
+ "vitest.config.mts",
24
+ ".*\\.spec.ts$",
25
+ ".*\\.test.ts$",
26
+ ".*.js$"
27
+ ]
28
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ ![npm version](https://img.shields.io/npm/v/<%- fullProjectName %>)
2
+ ![npm downloads](https://img.shields.io/npm/dm/<%- fullProjectName %>)
3
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/<%- ownerUsername %>/<%- repositoryName %>/ci.yml)
4
+ ![bundle size](https://img.shields.io/bundlephobia/min/<%- fullProjectName %>)
5
+
6
+
7
+ <p align="center">
8
+ <img src="./assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
9
+ </p>
10
+
11
+
12
+ ## <%- fullProjectName %>
13
+
14
+ - [ ] add description for <%- fullProjectName %>
15
+
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add <%- fullProjectName %>
21
+ ```
22
+
23
+ ## 💖 Support My Work
24
+ If you find my open-source contributions or the **<%- fullProjectName %>** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
25
+
26
+ [![CashApp](https://img.shields.io/badge/Sponsor%20me-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](<%- funding %>)
27
+
28
+
29
+ ---
30
+
31
+ ## 🤝 Connect with Me
32
+
33
+ <p align="left">
34
+ <a href="mailto:<%- email %>?subject=<%- fullProjectName %>">
35
+ <img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
36
+ </a>
37
+ </p>
@@ -0,0 +1,3 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [...baseConfig];
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "<%- fullProjectName %>",
3
+ "description": "- [ ] add project description",
4
+ "version": "<%- version %>",
5
+ "author": {
6
+ "name": "<%- currentUsername %>",
7
+ "email": "<%- email %>"
8
+ },
9
+ "homepage": "<%- homepage %>",
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "tag": "latest"
13
+ },
14
+ "keywords": [
15
+ "<% shortProjectName %>"
16
+ ],
17
+ "funding": <%- JSON.stringify(funding) %>,
18
+ "type": "module",
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ "./package.json": "./package.json",
24
+ ".": {
25
+ "@<%- repositoryName %>/source": "./src/index.ts",
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "assets",
34
+ "!**/*.tsbuildinfo"
35
+ ],
36
+ "nx": {
37
+ "sourceRoot": "<%- directory %>/src",
38
+ "targets": {
39
+ "build": {
40
+ "executor": "@nx/js:swc",
41
+ "outputs": [
42
+ "{options.outputPath}"
43
+ ],
44
+ "options": {
45
+ "outputPath": "<%- directory %>/dist",
46
+ "main": "<%- directory %>/src/index.ts",
47
+ "tsConfig": "<%- directory %>/tsconfig.lib.json",
48
+ "skipTypeCheck": true,
49
+ "stripLeadingPaths": true
50
+ }
51
+ }
52
+ }
53
+ },
54
+ "dependencies": {
55
+ "@swc/helpers": "~0.5.11"
56
+ },
57
+ "devDependencies": {
58
+ "vitest": "^4.0.8"
59
+ }
60
+ }
@@ -0,0 +1,3 @@
1
+ // @index(['./**/*.ts', '!./**/*.{test,spec}.ts'], f => `export * from '${f.path}.js'`)
2
+ export * from './lib/<%- fileName %>.js';
3
+
@@ -0,0 +1,7 @@
1
+ import { <%- propertyName %> } from './<%- fileName %>.js';
2
+
3
+ describe("<%- propertyName %>", ()=>{
4
+ it("should work", ()=>{
5
+ expect(<%- propertyName %>()).toEqual('<%- fileName %>')
6
+ })
7
+ })
@@ -0,0 +1,3 @@
1
+ export function <%- propertyName %>(){
2
+ return '<%- fileName %>'
3
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": "src",
6
+ "outDir": "dist",
7
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
8
+ "emitDeclarationOnly": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "types": [
11
+ "node"
12
+ ]
13
+ },
14
+ "include": [
15
+ "src/**/*.ts"
16
+ ],
17
+ "references": [],
18
+ "exclude": [
19
+ "vite.config.ts",
20
+ "vitest.config.mts",
21
+ "src/**/*.test.ts",
22
+ "src/**/*.spec.ts"
23
+ ]
24
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./out-tsc/vitest",
5
+ "types": [
6
+ "vitest/globals",
7
+ "vitest/importMeta",
8
+ "vite/client",
9
+ "node",
10
+ "vitest"
11
+ ],
12
+ "forceConsistentCasingInFileNames": true
13
+ },
14
+ "include": [
15
+ "vite.config.ts",
16
+ "vitest.config.mts",
17
+ "src/**/*.test.ts",
18
+ "src/**/*.spec.ts",
19
+ "src/**/*.d.ts"
20
+ ],
21
+ "references": [
22
+ {
23
+ "path": "./tsconfig.lib.json"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,20 @@
1
+ /// <reference types='vitest' />
2
+ import { defineConfig } from 'vite';
3
+
4
+ export default defineConfig(() => ({
5
+ root: import.meta.dirname,
6
+ cacheDir: '../../node_modules/.vite/<%- directory %>',
7
+ plugins: [],
8
+ test: {
9
+ name: '<%- fullProjectName %>',
10
+ watch: false,
11
+ globals: true,
12
+ environment: 'node',
13
+ include: ['{src,tests}/**/*.{test,spec}.ts'],
14
+ reporters: ['default'],
15
+ coverage: {
16
+ reportsDirectory: './test-output/vitest/coverage',
17
+ provider: 'v8' as const,
18
+ },
19
+ },
20
+ }));
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig(() => ({
4
+ root: __dirname,
5
+ cacheDir: '../../node_modules/.vite/<%- directory %>',
6
+ test: {
7
+ name: '<%- fullProjectName %>',
8
+ watch: false,
9
+ globals: true,
10
+ environment: 'node',
11
+ include: ['{src,tests}/**/*.{test,spec}.ts'],
12
+ reporters: ['default'],
13
+ coverage: {
14
+ reportsDirectory: './test-output/vitest/coverage',
15
+ provider: 'v8' as const,
16
+ },
17
+ },
18
+ }));
@@ -0,0 +1,19 @@
1
+ import type { ProjectGeneratorSchema } from './schema';
2
+ export type NormalizedProjectOptions = {
3
+ name: string;
4
+ version: string;
5
+ funding: Record<string, unknown>[];
6
+ shortProjectName: string;
7
+ fullProjectName: string;
8
+ repositoryName: string;
9
+ homepage: string;
10
+ email: string;
11
+ directory: string;
12
+ currentUsername: string;
13
+ ownerUsername: string;
14
+ type: string;
15
+ source: string;
16
+ target: string;
17
+ };
18
+ export declare function projectOptions(options: ProjectGeneratorSchema): Promise<NormalizedProjectOptions>;
19
+ //# sourceMappingURL=project-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-options.d.ts","sourceRoot":"","sources":["../../../src/generators/project/project-options.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,cAAc,CAClC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CAiDnC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.projectOptions = projectOptions;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const git_1 = require("../../common/git");
7
+ async function projectOptions(options) {
8
+ const type = options.type;
9
+ const directory = (0, path_1.normalize)(options.directory).split(/[\\/]/).join('/');
10
+ const source = (0, path_1.join)(__dirname, options.type);
11
+ const target = directory;
12
+ const main = await (0, devkit_1.readJsonFile)((0, path_1.join)(devkit_1.workspaceRoot, 'package.json'));
13
+ const funding = main.funding ?? [
14
+ { type: 'CashApp', url: 'https://cash.app/$puqlib' },
15
+ ];
16
+ const shortProjectName = options.directory.split(/[\\/]/).pop();
17
+ if (shortProjectName === undefined) {
18
+ throw new Error('Short project name could not be determined');
19
+ }
20
+ const email = (0, git_1.suffixEmail)((0, git_1.gitEmail)(), shortProjectName.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase());
21
+ const repoUrl = (0, git_1.gitRepoUrl)();
22
+ const repositoryName = (0, git_1.gitRepoName)(repoUrl);
23
+ const fullProjectName = `@${repositoryName}/${shortProjectName}`;
24
+ const currentUsername = (0, git_1.gitCurrentUsername)();
25
+ const ownerUsername = (0, git_1.gitRepoOwnerUsername)(repoUrl);
26
+ const version = main.version ?? '0.0.1';
27
+ const homepage = (0, git_1.githubPageForDoc)(repoUrl, options.directory);
28
+ return {
29
+ version,
30
+ funding,
31
+ shortProjectName,
32
+ fullProjectName,
33
+ repositoryName,
34
+ email,
35
+ homepage,
36
+ directory,
37
+ currentUsername,
38
+ ownerUsername,
39
+ type,
40
+ source,
41
+ target,
42
+ ...(0, devkit_1.names)(shortProjectName),
43
+ };
44
+ }
@@ -0,0 +1,5 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { ProjectGeneratorSchema } from './schema';
3
+ export declare function projectGenerator(tree: Tree, options: ProjectGeneratorSchema): Promise<void>;
4
+ export default projectGenerator;
5
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/generators/project/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,iBAahC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.projectGenerator = projectGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const project_options_1 = require("./project-options");
6
+ const update_tsconfig_1 = require("./update-tsconfig");
7
+ async function projectGenerator(tree, options) {
8
+ const normalizedProjectOptions = await (0, project_options_1.projectOptions)(options);
9
+ await (0, devkit_1.generateFiles)(tree, normalizedProjectOptions.source, normalizedProjectOptions.target, normalizedProjectOptions);
10
+ (0, update_tsconfig_1.updateTsconfigReferences)(tree, normalizedProjectOptions);
11
+ await (0, devkit_1.formatFiles)(tree);
12
+ }
13
+ exports.default = projectGenerator;
@@ -0,0 +1,15 @@
1
+ import type { ProjectType } from './project';
2
+
3
+ export type ProjectType =
4
+ | 'api'
5
+ | 'cli'
6
+ | 'client'
7
+ | 'client-library'
8
+ | 'graphql'
9
+ | 'library'
10
+ | 'prisma';
11
+
12
+ export interface ProjectGeneratorSchema {
13
+ type: ProjectType;
14
+ directory: string;
15
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema#",
3
+ "$id": "Project",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "type": "string",
9
+ "description": "Project type",
10
+ "enum": [
11
+ "api",
12
+ "cli",
13
+ "client",
14
+ "client-library",
15
+ "graphql",
16
+ "library",
17
+ "prisma"
18
+ ],
19
+ "$default": {
20
+ "$source": "argv",
21
+ "index": 0
22
+ },
23
+ "x-prompt": "What project type would you like to use?"
24
+ },
25
+ "directory": {
26
+ "type": "string",
27
+ "description": "Project directory",
28
+ "$default": {
29
+ "$source": "argv",
30
+ "index": 1
31
+ },
32
+ "x-prompt": "What directory would you like to use?"
33
+ }
34
+ },
35
+ "required": [
36
+ "type",
37
+ "directory"
38
+ ]
39
+ }
@@ -0,0 +1,4 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { NormalizedProjectOptions } from './project-options';
3
+ export declare function updateTsconfigReferences(tree: Tree, normalizedOptions: NormalizedProjectOptions): Promise<void>;
4
+ //# sourceMappingURL=update-tsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-tsconfig.d.ts","sourceRoot":"","sources":["../../../src/generators/project/update-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,wBAAwB,iBAiB5C"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsconfigReferences = updateTsconfigReferences;
4
+ const devkit_1 = require("@nx/devkit");
5
+ async function updateTsconfigReferences(tree, normalizedOptions) {
6
+ await (0, devkit_1.updateJson)(tree, 'tsconfig.json', (value) => {
7
+ if (value.references == undefined) {
8
+ value.references = [];
9
+ }
10
+ const projectPath = `./${normalizedOptions.directory}`;
11
+ if (!value.references.find((e) => e.path === projectPath)) {
12
+ value.references.push({ path: projectPath });
13
+ }
14
+ return value;
15
+ });
16
+ }
@@ -0,0 +1 @@
1
+ const variable = "<%= name %>";
@@ -0,0 +1,5 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { ResourceGeneratorSchema } from './schema';
3
+ export declare function resourceGenerator(tree: Tree, options: ResourceGeneratorSchema): Promise<void>;
4
+ export default resourceGenerator;
5
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/generators/resource/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,uBAAuB,iBAWjC;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resourceGenerator = resourceGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const path = tslib_1.__importStar(require("path"));
7
+ async function resourceGenerator(tree, options) {
8
+ const projectRoot = `libs/${options.name}`;
9
+ (0, devkit_1.addProjectConfiguration)(tree, options.name, {
10
+ root: projectRoot,
11
+ projectType: 'library',
12
+ sourceRoot: `${projectRoot}/src`,
13
+ targets: {},
14
+ });
15
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectRoot, options);
16
+ await (0, devkit_1.formatFiles)(tree);
17
+ }
18
+ exports.default = resourceGenerator;
@@ -0,0 +1,3 @@
1
+ export interface ResourceGeneratorSchema {
2
+ name: string;
3
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "Resource",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use?"
15
+ }
16
+ },
17
+ "required": ["name"]
18
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ {
2
+ "generators": {
3
+ "project": {
4
+ "factory": "./dist/generators/project/project",
5
+ "schema": "./dist/generators/project/schema.json",
6
+ "description": "project generator"
7
+ },
8
+ "resource": {
9
+ "factory": "./dist/generators/resource/resource",
10
+ "schema": "./dist/generators/resource/schema.json",
11
+ "description": "resource generator"
12
+ },
13
+ "component": {
14
+ "factory": "./dist/generators/component/component",
15
+ "schema": "./dist/generators/component/schema.json",
16
+ "description": "component generator"
17
+ }
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@robert-brightline/plugin",
3
+ "description": "Utility function to create name variants.",
4
+ "version": "0.0.1",
5
+ "author": {
6
+ "name": "robert-brightline",
7
+ "email": "robert.brightline+names@gmail.com"
8
+ },
9
+ "homepage": "https://github.com/robert-brightline/robert-brightline.git/libs/names",
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "tag": "latest"
13
+ },
14
+ "keywords": [
15
+ "nx",
16
+ "plugin",
17
+ "generators"
18
+ ],
19
+ "funding": [
20
+ {
21
+ "type": "cashapp",
22
+ "url": "https://cash.app/$puqlib"
23
+ }
24
+ ],
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ "./package.json": "./package.json",
30
+ ".": {
31
+ "@robert-brightline/source": "./src/index.ts",
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "default": "./dist/index.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "!**/*.tsbuildinfo",
40
+ "generators.json"
41
+ ],
42
+ "nx": {
43
+ "targets": {
44
+ "build": {
45
+ "executor": "@nx/js:tsc",
46
+ "outputs": [
47
+ "{options.outputPath}"
48
+ ],
49
+ "options": {
50
+ "outputPath": "plugins/plugin/dist",
51
+ "main": "plugins/plugin/src/index.ts",
52
+ "tsConfig": "plugins/plugin/tsconfig.lib.json",
53
+ "rootDir": "plugins/plugin/src",
54
+ "generatePackageJson": false,
55
+ "assets": [
56
+ {
57
+ "input": "./plugins/plugin/src",
58
+ "glob": "**/!(*.ts)",
59
+ "output": "."
60
+ },
61
+ {
62
+ "input": "./plugins/plugin/src",
63
+ "glob": "**/*.d.ts",
64
+ "output": "."
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ },
71
+ "dependencies": {
72
+ "@nx/devkit": "22.3.3",
73
+ "tslib": "^2.3.0"
74
+ },
75
+ "devDependencies": {
76
+ "vitest": "^4.0.8"
77
+ },
78
+ "generators": "./generators.json"
79
+ }