@vnodes/cli 0.1.9 → 0.1.11
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/dist/cli/bye/bye.d.ts +1 -1
- package/dist/cli/bye/bye.d.ts.map +1 -1
- package/dist/cli/bye/bye.js.map +1 -1
- package/dist/cli/hello/hello.d.ts +1 -1
- package/dist/cli/hello/hello.d.ts.map +1 -1
- package/dist/cli/hello/hello.js.map +1 -1
- package/dist/cli/rm/rm.d.ts +2 -2
- package/dist/cli/rm/rm.d.ts.map +1 -1
- package/dist/cli/rm/rm.js +7 -5
- package/dist/cli/rm/rm.js.map +1 -1
- package/dist/cli/suffix/suffix.d.ts +7 -3
- package/dist/cli/suffix/suffix.d.ts.map +1 -1
- package/dist/cli/suffix/suffix.js +13 -7
- package/dist/cli/suffix/suffix.js.map +1 -1
- package/dist/cli/wd/wd.d.ts +1 -1
- package/dist/cli/wd/wd.d.ts.map +1 -1
- package/dist/cli/wd/wd.js.map +1 -1
- package/dist/cli/workspace/files/.eslint/eslint.base.mjs.template +2 -1
- package/dist/cli/workspace/files/.eslint/module-boundries.mjs.template +7 -2
- package/dist/cli/workspace/files/.eslint/type-import.mjs.template +14 -0
- package/dist/cli/workspace/files/.husky/pre-commit.template +2 -1
- package/dist/cli/workspace/files/.vscode/launch.json.template +23 -0
- package/dist/cli/workspace/files/.vscode/prisma.code-snippets.template +38 -0
- package/dist/cli/workspace/files/.vscode/settings.json.template +5 -2
- package/dist/cli/workspace/files/.vscode/ts.code-snippets.template +4 -1
- package/dist/cli/workspace/workspace.d.ts +3 -3
- package/dist/cli/workspace/workspace.d.ts.map +1 -1
- package/dist/cli/workspace/workspace.js +21 -25
- package/dist/cli/workspace/workspace.js.map +1 -1
- package/dist/generators/project/api/.env.template +2 -2
- package/dist/generators/project/api/package.json.template +1 -1
- package/dist/generators/project/api/src/app/resources/resource.module.ts.template +1 -1
- package/dist/generators/project/api/src/app/resources/sample/sample.controller.ts.template +1 -1
- package/dist/generators/project/api/src/app/resources/sample/sample.module.ts.template +1 -1
- package/dist/generators/project/prisma/.env.template +2 -2
- package/dist/generators/project/prisma/package.json.template +1 -2
- package/dist/generators/project/project.d.ts +2 -0
- package/dist/generators/project/project.d.ts.map +1 -1
- package/dist/generators/project/project.js +14 -8
- package/dist/generators/project/project.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/dist/generators/project/api/prisma/schema.prisma.template +0 -14
package/dist/cli/bye/bye.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bye.d.ts","sourceRoot":"","sources":["../../../src/cli/bye/bye.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"bye.d.ts","sourceRoot":"","sources":["../../../src/cli/bye/bye.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,QAKnC"}
|
package/dist/cli/bye/bye.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/bye/bye.ts"],"sourcesContent":["import { Command } from 'commander';\n\n/**\n * Say bye\n *\n * ### Example\n * ````sh\n * vnodes bye --username YourName\n * ````\n * @param command main command instance\n */\nexport function bye(command: Command) {\n command\n .command('bye')\n .requiredOption('-u, --username <string>', 'What is your name')\n .action(({ username }) => console.log(`Hello, ${username}`));\n}\n"],"names":["bye","command","requiredOption","action","username","console","log"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,IAAIC,OAAgB;IAClCA,QACGA,OAAO,CAAC,OACRC,cAAc,CAAC,2BAA2B,qBAC1CC,MAAM,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKC,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,UAAU;AAC9D"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/bye/bye.ts"],"sourcesContent":["import { type Command } from 'commander';\n\n/**\n * Say bye\n *\n * ### Example\n * ````sh\n * vnodes bye --username YourName\n * ````\n * @param command main command instance\n */\nexport function bye(command: Command) {\n command\n .command('bye')\n .requiredOption('-u, --username <string>', 'What is your name')\n .action(({ username }) => console.log(`Hello, ${username}`));\n}\n"],"names":["bye","command","requiredOption","action","username","console","log"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,IAAIC,OAAgB;IAClCA,QACGA,OAAO,CAAC,OACRC,cAAc,CAAC,2BAA2B,qBAC1CC,MAAM,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKC,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,UAAU;AAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../../src/cli/hello/hello.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../../src/cli/hello/hello.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,QAKrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/hello/hello.ts"],"sourcesContent":["import { Command } from 'commander';\n\n/**\n * Say hello to the user\n *\n * ### Example\n * ````sh\n * vnodes hello --username YourName\n * ````\n * @param command main command instance\n */\nexport function hello(command: Command) {\n command\n .command('hello')\n .requiredOption('-u, --username <string>', 'What is your name')\n .action(({ username }) => console.log(`Hello, ${username}`));\n}\n"],"names":["hello","command","requiredOption","action","username","console","log"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,MAAMC,OAAgB;IACpCA,QACGA,OAAO,CAAC,SACRC,cAAc,CAAC,2BAA2B,qBAC1CC,MAAM,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKC,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,UAAU;AAC9D"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/hello/hello.ts"],"sourcesContent":["import { type Command } from 'commander';\n\n/**\n * Say hello to the user\n *\n * ### Example\n * ````sh\n * vnodes hello --username YourName\n * ````\n * @param command main command instance\n */\nexport function hello(command: Command) {\n command\n .command('hello')\n .requiredOption('-u, --username <string>', 'What is your name')\n .action(({ username }) => console.log(`Hello, ${username}`));\n}\n"],"names":["hello","command","requiredOption","action","username","console","log"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,MAAMC,OAAgB;IACpCA,QACGA,OAAO,CAAC,SACRC,cAAc,CAAC,2BAA2B,qBAC1CC,MAAM,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKC,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,UAAU;AAC9D"}
|
package/dist/cli/rm/rm.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
2
|
/**
|
|
3
3
|
* Remove files/directories
|
|
4
4
|
*
|
|
5
5
|
* ### Example
|
|
6
6
|
* ````sh
|
|
7
|
-
* vnodes rm --
|
|
7
|
+
* vnodes rm --path some/path/to/delete
|
|
8
8
|
* ````
|
|
9
9
|
* @param command main command instance
|
|
10
10
|
*/
|
package/dist/cli/rm/rm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../src/cli/rm/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../src/cli/rm/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;;;;GAQG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,QASlC"}
|
package/dist/cli/rm/rm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rm as nodeRm } from 'node:fs/promises';
|
|
2
2
|
import { scope } from '@vnodes/fs';
|
|
3
3
|
import { cwd } from 'node:process';
|
|
4
4
|
/**
|
|
@@ -6,15 +6,17 @@ import { cwd } from 'node:process';
|
|
|
6
6
|
*
|
|
7
7
|
* ### Example
|
|
8
8
|
* ````sh
|
|
9
|
-
* vnodes rm --
|
|
9
|
+
* vnodes rm --path some/path/to/delete
|
|
10
10
|
* ````
|
|
11
11
|
* @param command main command instance
|
|
12
12
|
*/ export function rm(command) {
|
|
13
|
-
command.command('rm').requiredOption('-p, --path <string>', '
|
|
13
|
+
command.command('rm').description('Remove all directories/files under the given path.').requiredOption('-p, --path <string>', 'Path to delete').action(async ({ path })=>{
|
|
14
14
|
const resolve = scope(cwd());
|
|
15
|
-
|
|
15
|
+
await nodeRm(resolve(path), {
|
|
16
16
|
recursive: true,
|
|
17
|
-
force: true
|
|
17
|
+
force: true,
|
|
18
|
+
maxRetries: 3,
|
|
19
|
+
retryDelay: 400
|
|
18
20
|
});
|
|
19
21
|
});
|
|
20
22
|
}
|
package/dist/cli/rm/rm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/rm/rm.ts"],"sourcesContent":["import { Command } from 'commander';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/rm/rm.ts"],"sourcesContent":["import { type Command } from 'commander';\nimport { rm as nodeRm } from 'node:fs/promises';\nimport { scope } from '@vnodes/fs';\nimport { cwd } from 'node:process';\n/**\n * Remove files/directories\n *\n * ### Example\n * ````sh\n * vnodes rm --path some/path/to/delete\n * ````\n * @param command main command instance\n */\nexport function rm(command: Command) {\n command\n .command('rm')\n .description('Remove all directories/files under the given path.')\n .requiredOption('-p, --path <string>', 'Path to delete')\n .action(async ({ path }) => {\n const resolve = scope(cwd());\n await nodeRm(resolve(path), { recursive: true, force: true, maxRetries: 3, retryDelay: 400 });\n });\n}\n"],"names":["rm","nodeRm","scope","cwd","command","description","requiredOption","action","path","resolve","recursive","force","maxRetries","retryDelay"],"mappings":"AACA,SAASA,MAAMC,MAAM,QAAQ,mBAAmB;AAChD,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,GAAG,QAAQ,eAAe;AACnC;;;;;;;;CAQC,GACD,OAAO,SAASH,GAAGI,OAAgB;IACjCA,QACGA,OAAO,CAAC,MACRC,WAAW,CAAC,sDACZC,cAAc,CAAC,uBAAuB,kBACtCC,MAAM,CAAC,OAAO,EAAEC,IAAI,EAAE;QACrB,MAAMC,UAAUP,MAAMC;QACtB,MAAMF,OAAOQ,QAAQD,OAAO;YAAEE,WAAW;YAAMC,OAAO;YAAMC,YAAY;YAAGC,YAAY;QAAI;IAC7F;AACJ"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
2
|
/**
|
|
3
|
-
* Suffix file/files recursive
|
|
3
|
+
* Suffix file/files recursive (optional)
|
|
4
4
|
*
|
|
5
5
|
* ### Example
|
|
6
6
|
* ````sh
|
|
7
|
-
*
|
|
7
|
+
* # Add .template suffix
|
|
8
|
+
* vnodes suffix --s .template -r
|
|
9
|
+
*
|
|
10
|
+
* # Remove the .template suffix
|
|
11
|
+
* vnodes suffix --s .template -r -u
|
|
8
12
|
* ````
|
|
9
13
|
* @param command main command instance
|
|
10
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suffix.d.ts","sourceRoot":"","sources":["../../../src/cli/suffix/suffix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"suffix.d.ts","sourceRoot":"","sources":["../../../src/cli/suffix/suffix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,QAwBtC"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renameSync } from 'node:fs';
|
|
2
|
+
import { readdir } from 'node:fs/promises';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
/**
|
|
4
|
-
* Suffix file/files recursive
|
|
5
|
+
* Suffix file/files recursive (optional)
|
|
5
6
|
*
|
|
6
7
|
* ### Example
|
|
7
8
|
* ````sh
|
|
8
|
-
*
|
|
9
|
+
* # Add .template suffix
|
|
10
|
+
* vnodes suffix --s .template -r
|
|
11
|
+
*
|
|
12
|
+
* # Remove the .template suffix
|
|
13
|
+
* vnodes suffix --s .template -r -u
|
|
9
14
|
* ````
|
|
10
15
|
* @param command main command instance
|
|
11
16
|
*/ export function suffix(command) {
|
|
12
|
-
command.command('suffix').option('-u, --undo', '
|
|
13
|
-
const
|
|
17
|
+
command.command('suffix').option('-u, --undo', 'Remove the suffix from file names').option('-r, --recursive', 'Apply suffix to all files under sub directories').requiredOption('-s, --suffix <string>', 'Suffix to append to the file names').action(async ({ suffix, recursive, undo })=>{
|
|
18
|
+
const foundDirs = await readdir('./', {
|
|
14
19
|
recursive: !!recursive,
|
|
15
20
|
withFileTypes: true
|
|
16
|
-
})
|
|
21
|
+
});
|
|
22
|
+
const absolutePaths = foundDirs.filter((e)=>e.isFile()).map((e)=>join(e.parentPath, e.name));
|
|
17
23
|
const createNewFilepath = (filePath)=>{
|
|
18
24
|
return undo ? filePath.replace(new RegExp(`${suffix}$`), '') : `${filePath}${suffix}`;
|
|
19
25
|
};
|
|
20
|
-
for (const filePath of
|
|
26
|
+
for (const filePath of absolutePaths){
|
|
21
27
|
renameSync(filePath, createNewFilepath(filePath));
|
|
22
28
|
}
|
|
23
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/suffix/suffix.ts"],"sourcesContent":["import { Command } from 'commander';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/suffix/suffix.ts"],"sourcesContent":["import { type Command } from 'commander';\nimport { renameSync } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Suffix file/files recursive (optional)\n *\n * ### Example\n * ````sh\n * # Add .template suffix\n * vnodes suffix --s .template -r\n *\n * # Remove the .template suffix\n * vnodes suffix --s .template -r -u\n * ````\n * @param command main command instance\n */\nexport function suffix(command: Command) {\n command\n .command('suffix')\n .option('-u, --undo', 'Remove the suffix from file names')\n .option('-r, --recursive', 'Apply suffix to all files under sub directories')\n .requiredOption('-s, --suffix <string>', 'Suffix to append to the file names')\n .action(async ({ suffix, recursive, undo }) => {\n const foundDirs = await readdir('./', {\n recursive: !!recursive,\n withFileTypes: true,\n });\n\n const absolutePaths = foundDirs\n .filter((e) => e.isFile())\n .map((e) => join(e.parentPath, e.name));\n\n const createNewFilepath = (filePath: string) => {\n return undo ? filePath.replace(new RegExp(`${suffix}$`), '') : `${filePath}${suffix}`;\n };\n\n for (const filePath of absolutePaths) {\n renameSync(filePath, createNewFilepath(filePath));\n }\n });\n}\n"],"names":["renameSync","readdir","join","suffix","command","option","requiredOption","action","recursive","undo","foundDirs","withFileTypes","absolutePaths","filter","e","isFile","map","parentPath","name","createNewFilepath","filePath","replace","RegExp"],"mappings":"AACA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,OAAO,QAAQ,mBAAmB;AAC3C,SAASC,IAAI,QAAQ,YAAY;AAEjC;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,OAAOC,OAAgB;IACrCA,QACGA,OAAO,CAAC,UACRC,MAAM,CAAC,cAAc,qCACrBA,MAAM,CAAC,mBAAmB,mDAC1BC,cAAc,CAAC,yBAAyB,sCACxCC,MAAM,CAAC,OAAO,EAAEJ,MAAM,EAAEK,SAAS,EAAEC,IAAI,EAAE;QACxC,MAAMC,YAAY,MAAMT,QAAQ,MAAM;YACpCO,WAAW,CAAC,CAACA;YACbG,eAAe;QACjB;QAEA,MAAMC,gBAAgBF,UACnBG,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,IACtBC,GAAG,CAAC,CAACF,IAAMZ,KAAKY,EAAEG,UAAU,EAAEH,EAAEI,IAAI;QAEvC,MAAMC,oBAAoB,CAACC;YACzB,OAAOX,OAAOW,SAASC,OAAO,CAAC,IAAIC,OAAO,GAAGnB,OAAO,CAAC,CAAC,GAAG,MAAM,GAAGiB,WAAWjB,QAAQ;QACvF;QAEA,KAAK,MAAMiB,YAAYR,cAAe;YACpCZ,WAAWoB,UAAUD,kBAAkBC;QACzC;IACF;AACJ"}
|
package/dist/cli/wd/wd.d.ts
CHANGED
package/dist/cli/wd/wd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wd.d.ts","sourceRoot":"","sources":["../../../src/cli/wd/wd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"wd.d.ts","sourceRoot":"","sources":["../../../src/cli/wd/wd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC;;;;;;;;GAQG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,QAIlC"}
|
package/dist/cli/wd/wd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/wd/wd.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { cwd } from 'node:process';\n\n/**\n * Print the current working directory\n *\n * ### Example\n * ````sh\n * vnodes hello --username YourName\n * ````\n * @param command main command instance\n */\nexport function wd(command: Command) {\n command.command('wd').action(() => {\n console.log(cwd());\n });\n}\n"],"names":["cwd","wd","command","action","console","log"],"mappings":"AACA,SAASA,GAAG,QAAQ,eAAe;AAEnC;;;;;;;;CAQC,GACD,OAAO,SAASC,GAAGC,OAAgB;IACjCA,QAAQA,OAAO,CAAC,MAAMC,MAAM,CAAC;QAC3BC,QAAQC,GAAG,CAACL;IACd;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/wd/wd.ts"],"sourcesContent":["import { type Command } from 'commander';\nimport { cwd } from 'node:process';\n\n/**\n * Print the current working directory\n *\n * ### Example\n * ````sh\n * vnodes hello --username YourName\n * ````\n * @param command main command instance\n */\nexport function wd(command: Command) {\n command.command('wd').action(() => {\n console.log(cwd());\n });\n}\n"],"names":["cwd","wd","command","action","console","log"],"mappings":"AACA,SAASA,GAAG,QAAQ,eAAe;AAEnC;;;;;;;;CAQC,GACD,OAAO,SAASC,GAAGC,OAAgB;IACjCA,QAAQA,OAAO,CAAC,MAAMC,MAAM,CAAC;QAC3BC,QAAQC,GAAG,CAACL;IACd;AACF"}
|
|
@@ -4,5 +4,6 @@ import dependencyCheck from './dependency-check.mjs';
|
|
|
4
4
|
import moduleBoundries from './module-boundries.mjs';
|
|
5
5
|
import noUndefined from './no-undefined.mjs';
|
|
6
6
|
import nodeProtocol from './node-protocol.mjs';
|
|
7
|
+
import typeImport from './type-import.mjs';
|
|
7
8
|
|
|
8
|
-
export default [...common, ...dependencyCheck, ...moduleBoundries, ...noUndefined, ...nodeProtocol];
|
|
9
|
+
export default [...common, ...dependencyCheck, ...moduleBoundries, ...noUndefined, ...nodeProtocol, ...typeImport];
|
|
@@ -9,13 +9,18 @@ export default [
|
|
|
9
9
|
allow: ['^.*/eslint(\\.base)?\\.config\\.mjs$'],
|
|
10
10
|
depConstraints: [
|
|
11
11
|
{
|
|
12
|
-
sourceTag: 'app
|
|
13
|
-
onlyDependOnLibsWithTags: ['lib:core', 'lib:module', 'lib:shared', 'lib:types'],
|
|
12
|
+
sourceTag: 'app:db',
|
|
13
|
+
onlyDependOnLibsWithTags: ['app:db', 'lib:core', 'lib:module', 'lib:shared', 'lib:types'],
|
|
14
14
|
},
|
|
15
|
+
|
|
15
16
|
{
|
|
16
17
|
sourceTag: 'app:api',
|
|
17
18
|
onlyDependOnLibsWithTags: ['app:db', 'lib:core', 'lib:module', 'lib:shared', 'lib:types'],
|
|
18
19
|
},
|
|
20
|
+
{
|
|
21
|
+
sourceTag: 'app:cli',
|
|
22
|
+
onlyDependOnLibsWithTags: ['lib:core', 'lib:module', 'lib:shared', 'lib:types'],
|
|
23
|
+
},
|
|
19
24
|
{
|
|
20
25
|
sourceTag: 'lib:core',
|
|
21
26
|
onlyDependOnLibsWithTags: ['lib:module', 'lib:shared', 'lib:types'],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# #!/bin/bash
|
|
2
2
|
|
|
3
3
|
pnpm nx affected -t prisma:generate --tuiAutoExit=true
|
|
4
|
-
pnpm nx affected -t lint --tuiAutoExit=true
|
|
4
|
+
pnpm nx affected -t lint --fix --tuiAutoExit=true
|
|
5
5
|
pnpm nx affected -t build --tuiAutoExit=true
|
|
6
6
|
pnpm nx affected -t test --tuiAutoExit=true
|
|
7
|
+
git add .
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "Debug @vnodes/sample-api with Nx",
|
|
8
|
+
"runtimeExecutable": "pnpm",
|
|
9
|
+
"runtimeArgs": ["exec", "nx", "serve", "@vnodes/sample-api"],
|
|
10
|
+
"env": {
|
|
11
|
+
"NODE_OPTIONS": "--inspect=9229"
|
|
12
|
+
},
|
|
13
|
+
"console": "integratedTerminal",
|
|
14
|
+
"internalConsoleOptions": "neverOpen",
|
|
15
|
+
"skipFiles": ["<node_internals>/**"],
|
|
16
|
+
"sourceMaps": true,
|
|
17
|
+
"outFiles": [
|
|
18
|
+
"${workspaceFolder}/apis/sample-api/dist/**/*.(m|c|)js",
|
|
19
|
+
"!**/node_modules/**"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prisma model": {
|
|
3
|
+
"prefix": "model",
|
|
4
|
+
"body": [
|
|
5
|
+
"model $1 {",
|
|
6
|
+
" id Int @id @default(autoincrement())",
|
|
7
|
+
" createdAt DateTime @default(now()) @map(\"created_at\")",
|
|
8
|
+
" updatedAt DateTime @updatedAt @map(\"updated_at\")",
|
|
9
|
+
" deletedAt DateTime? @map(\"deleted_at\")",
|
|
10
|
+
" isActive Boolean @default(true) @map(\"is_active\")",
|
|
11
|
+
" createdBy User? @relation(fields: [createdByUserId], references: [id], onDelete: SetNull, onUpdate: Cascade)",
|
|
12
|
+
" createdByUserId Int? @map(\"created_by_user_id\")",
|
|
13
|
+
" name String @unique",
|
|
14
|
+
" description String?",
|
|
15
|
+
"",
|
|
16
|
+
"$0",
|
|
17
|
+
"@@map(\"${1/(^[A-Z])|(?<=[a-z0-9])([A-Z])/${1:/downcase}${2:+_${2:/downcase}/g}\")",
|
|
18
|
+
"}",
|
|
19
|
+
],
|
|
20
|
+
"scope": "prisma"
|
|
21
|
+
},
|
|
22
|
+
"prisma model map": {
|
|
23
|
+
"prefix": "prisma model map",
|
|
24
|
+
"body": [
|
|
25
|
+
"model ${1}${2} {",
|
|
26
|
+
" ${1/([A-Z])/${1:/downcase}/g} $1 @relation(fields: [${1/([A-Z])/${1:/downcase}/g}Id], references: [id], onDelete: Cascade, onUpdate: Cascade)",
|
|
27
|
+
" ${1/([A-Z])/${1:/downcase}/g}Id Int @map(\"${1/([A-Z])/${1:/downcase}/g}_id\")",
|
|
28
|
+
"",
|
|
29
|
+
" ${2/([A-Z])/${1:/downcase}/g} $2 @relation(fields: [${2/([A-Z])/${1:/downcase}/g}Id], references: [id], onDelete: Cascade, onUpdate: Cascade)",
|
|
30
|
+
" ${2/([A-Z])/${1:/downcase}/g}Id Int @map(\"${2/([A-Z])/${1:/downcase}/g}_id\")",
|
|
31
|
+
"",
|
|
32
|
+
" @@unique([${1/([A-Z])/${1:/downcase}/g}Id, ${2/([A-Z])/${1:/downcase}/g}Id])",
|
|
33
|
+
" @@map(\"${1/([A-Z])/${1:/downcase}/g}_${2/([A-Z])/${1:/downcase}/g}s\")",
|
|
34
|
+
"}"
|
|
35
|
+
],
|
|
36
|
+
"scope": "prisma"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -17,11 +17,14 @@
|
|
|
17
17
|
"[typescript]": {
|
|
18
18
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
19
19
|
"editor.codeActionsOnSave": {
|
|
20
|
+
"source.organizeImports": "always",
|
|
21
|
+
"source.sortImports": "always",
|
|
22
|
+
"source.fixAll.ts": "always",
|
|
20
23
|
"source.fixAll.prettier": "always",
|
|
21
24
|
"source.fixAll.eslint": "always",
|
|
22
25
|
"source.removeUnused.ts": "always",
|
|
23
26
|
"source.addMissingImports.ts": "always",
|
|
24
|
-
"source.removeUnusedImports": "always"
|
|
27
|
+
"source.removeUnusedImports": "always"
|
|
25
28
|
}
|
|
26
|
-
}
|
|
29
|
+
}
|
|
27
30
|
}
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
},
|
|
11
11
|
"_dirname": {
|
|
12
12
|
"prefix": "_dirname",
|
|
13
|
-
"body":
|
|
13
|
+
"body": [
|
|
14
|
+
"import { dirname, join } from \"path\"",
|
|
15
|
+
"const __dirname = dirname(fileURLToPath(import.meta.url));",
|
|
16
|
+
],
|
|
14
17
|
"scope": "typescript"
|
|
15
18
|
}
|
|
16
19
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Generate nx workspace
|
|
4
4
|
*
|
|
5
5
|
* ### Example
|
|
6
6
|
* ````sh
|
|
7
|
-
* vnodes workspace --
|
|
7
|
+
* vnodes workspace --name WorkSpaceName
|
|
8
8
|
* ````
|
|
9
9
|
* @param command main command instance
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/cli/workspace/workspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/cli/workspace/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AA0CzC;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,QASzC"}
|
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import { copyFiles } from '@vnodes/fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { readdir } from 'node:fs/promises';
|
|
5
|
-
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
|
-
import ejs from 'ejs';
|
|
7
1
|
import { names } from '@nx/devkit';
|
|
2
|
+
import { copyFilesGenerator, filesGenerator, readTextFile, writeTextFile } from '@vnodes/fs';
|
|
3
|
+
import ejs from 'ejs';
|
|
4
|
+
import { mkdir } from 'node:fs/promises';
|
|
5
|
+
import { dirname, join, relative } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
8
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
8
|
async function geneateFiles(name) {
|
|
10
|
-
|
|
9
|
+
const removeTemplateSuffix = (filePath)=>{
|
|
11
10
|
return filePath.slice(0, -'.template'.length);
|
|
12
|
-
}
|
|
11
|
+
};
|
|
12
|
+
const copyFilesGeneartor = copyFilesGenerator(join(__dirname, 'files'), join(name), removeTemplateSuffix);
|
|
13
|
+
for await (const entry of copyFilesGeneartor){
|
|
14
|
+
console.log(`[ Created ] ${entry}`);
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
async function generateTemplates(name) {
|
|
15
18
|
const templateRootDir = join(__dirname, 'templates');
|
|
16
|
-
const templateFiles =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const templateFilePath = join(t.parentPath, t.name);
|
|
23
|
-
const templateFileContent = readFileSync(templateFilePath, {
|
|
24
|
-
encoding: 'utf-8'
|
|
25
|
-
});
|
|
26
|
-
const targetTemplateFilePath = join('./', name, templateFilePath.replace(templateRootDir, '')).slice(0, -'.ejs'.length);
|
|
27
|
-
mkdirSync(dirname(targetTemplateFilePath), {
|
|
19
|
+
const templateFiles = filesGenerator(templateRootDir);
|
|
20
|
+
for await (const filePath of templateFiles){
|
|
21
|
+
const templateFileContent = await readTextFile(filePath);
|
|
22
|
+
const relativeTemplateFilePath = relative(templateRootDir, filePath).slice(0, -'.ejs'.length);
|
|
23
|
+
const targetFilePath = join(name, relativeTemplateFilePath);
|
|
24
|
+
await mkdir(dirname(targetFilePath), {
|
|
28
25
|
recursive: true
|
|
29
26
|
});
|
|
30
27
|
const renderedContent = ejs.render(templateFileContent, {
|
|
31
28
|
...names(name),
|
|
32
29
|
email: `${name}@${name}.com`
|
|
33
30
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
31
|
+
await writeTextFile(targetFilePath, renderedContent);
|
|
32
|
+
console.log(`[ Created ] ${relativeTemplateFilePath} `);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
/**
|
|
40
|
-
*
|
|
36
|
+
* Generate nx workspace
|
|
41
37
|
*
|
|
42
38
|
* ### Example
|
|
43
39
|
* ````sh
|
|
44
|
-
* vnodes workspace --
|
|
40
|
+
* vnodes workspace --name WorkSpaceName
|
|
45
41
|
* ````
|
|
46
42
|
* @param command main command instance
|
|
47
43
|
*/ export function workspace(command) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/workspace/workspace.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/workspace/workspace.ts"],"sourcesContent":["import { names } from '@nx/devkit';\nimport { copyFilesGenerator, filesGenerator, readTextFile, writeTextFile } from '@vnodes/fs';\nimport { type Command } from 'commander';\nimport ejs from 'ejs';\nimport { mkdir } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nasync function geneateFiles(name: string) {\n const removeTemplateSuffix = (filePath: string) => {\n return filePath.slice(0, -'.template'.length);\n };\n const copyFilesGeneartor = copyFilesGenerator(\n join(__dirname, 'files'),\n join(name),\n removeTemplateSuffix,\n );\n\n for await (const entry of copyFilesGeneartor) {\n console.log(`[ Created ] ${entry}`);\n }\n}\n\nasync function generateTemplates(name: string) {\n const templateRootDir = join(__dirname, 'templates');\n const templateFiles = filesGenerator(templateRootDir);\n\n for await (const filePath of templateFiles) {\n const templateFileContent = await readTextFile(filePath);\n const relativeTemplateFilePath = relative(templateRootDir, filePath).slice(0, -'.ejs'.length);\n\n const targetFilePath = join(name, relativeTemplateFilePath);\n await mkdir(dirname(targetFilePath), { recursive: true });\n const renderedContent = ejs.render(templateFileContent, {\n ...names(name),\n email: `${name}@${name}.com`,\n });\n await writeTextFile(targetFilePath, renderedContent);\n console.log(`[ Created ] ${relativeTemplateFilePath} `);\n }\n}\n\n/**\n * Generate nx workspace\n *\n * ### Example\n * ````sh\n * vnodes workspace --name WorkSpaceName\n * ````\n * @param command main command instance\n */\nexport function workspace(command: Command) {\n command\n .command('workspace')\n .description('Generate a nx workspace')\n .requiredOption('-n, --name <string>', 'Project name')\n .action(async ({ name }) => {\n await geneateFiles(name);\n await generateTemplates(name);\n });\n}\n"],"names":["names","copyFilesGenerator","filesGenerator","readTextFile","writeTextFile","ejs","mkdir","dirname","join","relative","fileURLToPath","__dirname","url","geneateFiles","name","removeTemplateSuffix","filePath","slice","length","copyFilesGeneartor","entry","console","log","generateTemplates","templateRootDir","templateFiles","templateFileContent","relativeTemplateFilePath","targetFilePath","recursive","renderedContent","render","email","workspace","command","description","requiredOption","action"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAa;AACnC,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,YAAY,EAAEC,aAAa,QAAQ,aAAa;AAE7F,OAAOC,SAAS,MAAM;AACtB,SAASC,KAAK,QAAQ,mBAAmB;AACzC,SAASC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AACpD,SAASC,aAAa,QAAQ,WAAW;AAEzC,MAAMC,YAAYJ,QAAQG,cAAc,YAAYE,GAAG;AAEvD,eAAeC,aAAaC,IAAY;IACtC,MAAMC,uBAAuB,CAACC;QAC5B,OAAOA,SAASC,KAAK,CAAC,GAAG,CAAC,YAAYC,MAAM;IAC9C;IACA,MAAMC,qBAAqBlB,mBACzBO,KAAKG,WAAW,UAChBH,KAAKM,OACLC;IAGF,WAAW,MAAMK,SAASD,mBAAoB;QAC5CE,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAEF,OAAO;IACpC;AACF;AAEA,eAAeG,kBAAkBT,IAAY;IAC3C,MAAMU,kBAAkBhB,KAAKG,WAAW;IACxC,MAAMc,gBAAgBvB,eAAesB;IAErC,WAAW,MAAMR,YAAYS,cAAe;QAC1C,MAAMC,sBAAsB,MAAMvB,aAAaa;QAC/C,MAAMW,2BAA2BlB,SAASe,iBAAiBR,UAAUC,KAAK,CAAC,GAAG,CAAC,OAAOC,MAAM;QAE5F,MAAMU,iBAAiBpB,KAAKM,MAAMa;QAClC,MAAMrB,MAAMC,QAAQqB,iBAAiB;YAAEC,WAAW;QAAK;QACvD,MAAMC,kBAAkBzB,IAAI0B,MAAM,CAACL,qBAAqB;YACtD,GAAG1B,MAAMc,KAAK;YACdkB,OAAO,GAAGlB,KAAK,CAAC,EAAEA,KAAK,IAAI,CAAC;QAC9B;QACA,MAAMV,cAAcwB,gBAAgBE;QACpCT,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAEK,yBAAyB,CAAC,CAAC;IACxD;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASM,UAAUC,OAAgB;IACxCA,QACGA,OAAO,CAAC,aACRC,WAAW,CAAC,2BACZC,cAAc,CAAC,uBAAuB,gBACtCC,MAAM,CAAC,OAAO,EAAEvB,IAAI,EAAE;QACrB,MAAMD,aAAaC;QACnB,MAAMS,kBAAkBT;IAC1B;AACJ"}
|
|
@@ -3,5 +3,5 @@ APP_ID=<%- fileName %>
|
|
|
3
3
|
APP_DESC=- [ ] Add description
|
|
4
4
|
API_PREFIX=api
|
|
5
5
|
PORT=3000
|
|
6
|
-
DB_URL=postgres://<%- orgName %>:password@localhost:5432/<%- orgName %>?schema=<%-
|
|
7
|
-
DB_SCHEMA=<%-
|
|
6
|
+
DB_URL=postgres://<%- orgName %>:password@localhost:5432/<%- orgName %>?schema=<%- commonShortName %>
|
|
7
|
+
DB_SCHEMA=<%- commonShortName %>
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@vnodes/nest": "<%- workspaceVersion %>",
|
|
91
91
|
"@vnodes/prisma": "<%- workspaceVersion %>",
|
|
92
92
|
"@vnodes/types": "<%- workspaceVersion %>",
|
|
93
|
-
"<%-
|
|
93
|
+
"<%- databaseProjectName %>": "workspace:*",
|
|
94
94
|
"cache-manager": "^7.2.8",
|
|
95
95
|
"class-transformer": "^0.5.1",
|
|
96
96
|
"class-validator": "^0.15.1",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module } from '@vnodes/nest';
|
|
2
2
|
import { SampleModule } from './sample/sample.module.js';
|
|
3
3
|
import { PrismaModule } from '@vnodes/prisma';
|
|
4
|
-
import { PrismaClient } from '<%- projectName %>-db/client'
|
|
4
|
+
import { PrismaClient } from '<%- projectName %>-db/client';
|
|
5
5
|
|
|
6
6
|
@Module({
|
|
7
7
|
imports: [PrismaModule.forRoot({ client: PrismaClient }), SampleModule],
|
|
@@ -14,7 +14,7 @@ import { SampleCreateDto } from './sample.dto.js';
|
|
|
14
14
|
import { InjectDelegate } from '@vnodes/prisma';
|
|
15
15
|
import { Prisma } from '<%- projectName %>-db/client';
|
|
16
16
|
|
|
17
|
-
@ResourceController(
|
|
17
|
+
@ResourceController()
|
|
18
18
|
export class SampleController {
|
|
19
19
|
constructor(
|
|
20
20
|
@InjectDelegate(Prisma.ModelName.Sample)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module } from '@vnodes/nest';
|
|
2
2
|
import { SampleController } from './sample.controller.js';
|
|
3
3
|
import { PrismaModule } from '@vnodes/prisma';
|
|
4
|
-
import { Prisma } from '<%- projectName %>-db/client'
|
|
4
|
+
import { Prisma } from '<%- projectName %>-db/client';
|
|
5
5
|
|
|
6
6
|
@Module({
|
|
7
7
|
imports: [PrismaModule.forFeature({ models: [Prisma.ModelName.Sample] })],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
PROFILE=DEV
|
|
2
2
|
DB_MIGRATIONS_PATH=../../tmp/prisma/migrations/<%- fileName %>
|
|
3
|
-
DB_URL=postgres://<%- orgName %>:password@localhost:5432/<%- orgName %>?schema=<%-
|
|
4
|
-
DB_SCHEMA=<%-
|
|
3
|
+
DB_URL=postgres://<%- orgName %>:password@localhost:5432/<%- orgName %>?schema=<%- commonShortName %>
|
|
4
|
+
DB_SCHEMA=<%- commonShortName %>
|
|
@@ -9,6 +9,8 @@ export type NormalizedProjectGeneratorOptions = ProjectGeneratorSchema & {
|
|
|
9
9
|
targetRoot: string;
|
|
10
10
|
tag: string;
|
|
11
11
|
workspaceVersion: string;
|
|
12
|
+
databaseProjectName: string;
|
|
13
|
+
commonShortName: string;
|
|
12
14
|
} & ReturnType<typeof names>;
|
|
13
15
|
export declare function normalizeProjectSchema(options: ProjectGeneratorSchema): NormalizedProjectGeneratorOptions;
|
|
14
16
|
export declare function projectGenerator(tree: Tree, options: ProjectGeneratorSchema): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/generators/project/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/generators/project/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAGtF,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI9E,wBAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAaxD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAE3E;AAED,MAAM,MAAM,iCAAiC,GAAG,sBAAsB,GAAG;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AAE7B,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,sBAAsB,GAC9B,iCAAiC,CAsBnC;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,iBAuBjF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -23,18 +23,24 @@ export function brandEmail(orgName, shortName, email) {
|
|
|
23
23
|
return email.split('@').join(`+${orgName}-${shortName}@`);
|
|
24
24
|
}
|
|
25
25
|
export function normalizeProjectSchema(options) {
|
|
26
|
-
const
|
|
26
|
+
const n = {
|
|
27
27
|
...options
|
|
28
28
|
};
|
|
29
29
|
const shortName = basename(options.directory);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
n.shortName = shortName;
|
|
31
|
+
n.sourceRoot = join(__dirname, options.projectType);
|
|
32
|
+
n.targetRoot = join(options.directory);
|
|
33
|
+
n.projectName = `@${options.orgName}/${shortName}`;
|
|
34
|
+
n.tag = autoTag(n.projectType);
|
|
35
|
+
n.email = brandEmail(options.orgName, shortName, options.email);
|
|
36
|
+
if (n.projectName.match(/-api$/)) {
|
|
37
|
+
n.databaseProjectName = n.projectName.replace(/-api$/, '-db');
|
|
38
|
+
} else {
|
|
39
|
+
n.databaseProjectName = n.projectName + '-db';
|
|
40
|
+
}
|
|
41
|
+
n.commonShortName = n.shortName.replace(/-api$/, '').replace(/-db$/, '');
|
|
36
42
|
return {
|
|
37
|
-
...
|
|
43
|
+
...n,
|
|
38
44
|
...names(shortName)
|
|
39
45
|
};
|
|
40
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/generators/project/project.ts"],"sourcesContent":["import { formatFiles, generateFiles, names, updateJson, type Tree } from '@nx/devkit';\nimport { basename, dirname, join } from 'node:path';\nimport { type ProjectGeneratorSchema, type ProjectType } from './schema.d.js';\
|
|
1
|
+
{"version":3,"sources":["../../../src/generators/project/project.ts"],"sourcesContent":["import { formatFiles, generateFiles, names, updateJson, type Tree } from '@nx/devkit';\nimport { basename, dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { type ProjectGeneratorSchema, type ProjectType } from './schema.d.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport function autoTag(projectType: ProjectType): string {\n switch (projectType) {\n case 'lib': {\n return 'lib:shared';\n }\n case 'cli':\n case 'api': {\n return `app:${projectType}`;\n }\n case 'prisma': {\n return `app:db`;\n }\n }\n}\n\nexport function brandEmail(orgName: string, shortName: string, email: string) {\n return email.split('@').join(`+${orgName}-${shortName}@`);\n}\n\nexport type NormalizedProjectGeneratorOptions = ProjectGeneratorSchema & {\n projectName: string;\n shortName: string;\n sourceRoot: string;\n targetRoot: string;\n tag: string;\n workspaceVersion: string;\n databaseProjectName: string;\n commonShortName: string;\n} & ReturnType<typeof names>;\n\nexport function normalizeProjectSchema(\n options: ProjectGeneratorSchema,\n): NormalizedProjectGeneratorOptions {\n const n = { ...options } as NormalizedProjectGeneratorOptions;\n\n const shortName = basename(options.directory);\n\n n.shortName = shortName;\n\n n.sourceRoot = join(__dirname, options.projectType);\n n.targetRoot = join(options.directory);\n n.projectName = `@${options.orgName}/${shortName}`;\n n.tag = autoTag(n.projectType);\n n.email = brandEmail(options.orgName, shortName, options.email);\n\n if (n.projectName.match(/-api$/)) {\n n.databaseProjectName = n.projectName.replace(/-api$/, '-db');\n } else {\n n.databaseProjectName = n.projectName + '-db';\n }\n\n n.commonShortName = n.shortName.replace(/-api$/, '').replace(/-db$/, '');\n\n return { ...n, ...names(shortName) };\n}\n\nexport async function projectGenerator(tree: Tree, options: ProjectGeneratorSchema) {\n const normalizedOptions = normalizeProjectSchema(options);\n\n generateFiles(tree, normalizedOptions.sourceRoot, normalizedOptions.targetRoot, {\n ...normalizedOptions,\n });\n\n generateFiles(tree, join(__dirname, 'common'), normalizedOptions.targetRoot, {\n ...normalizedOptions,\n });\n\n updateJson(tree, 'tsconfig.json', (value) => {\n if (!value.references) {\n value.references = [];\n }\n\n value.references.push({\n path: `./${options.directory}`,\n });\n\n return value;\n });\n await formatFiles(tree);\n}\n\nexport default projectGenerator;\n"],"names":["formatFiles","generateFiles","names","updateJson","basename","dirname","join","fileURLToPath","__dirname","url","autoTag","projectType","brandEmail","orgName","shortName","email","split","normalizeProjectSchema","options","n","directory","sourceRoot","targetRoot","projectName","tag","match","databaseProjectName","replace","commonShortName","projectGenerator","tree","normalizedOptions","value","references","push","path"],"mappings":"AAAA,SAASA,WAAW,EAAEC,aAAa,EAAEC,KAAK,EAAEC,UAAU,QAAmB,aAAa;AACtF,SAASC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AACpD,SAASC,aAAa,QAAQ,WAAW;AAGzC,MAAMC,YAAYH,QAAQE,cAAc,YAAYE,GAAG;AAEvD,OAAO,SAASC,QAAQC,WAAwB;IAC9C,OAAQA;QACN,KAAK;YAAO;gBACV,OAAO;YACT;QACA,KAAK;QACL,KAAK;YAAO;gBACV,OAAO,CAAC,IAAI,EAAEA,aAAa;YAC7B;QACA,KAAK;YAAU;gBACb,OAAO,CAAC,MAAM,CAAC;YACjB;IACF;AACF;AAEA,OAAO,SAASC,WAAWC,OAAe,EAAEC,SAAiB,EAAEC,KAAa;IAC1E,OAAOA,MAAMC,KAAK,CAAC,KAAKV,IAAI,CAAC,CAAC,CAAC,EAAEO,QAAQ,CAAC,EAAEC,UAAU,CAAC,CAAC;AAC1D;AAaA,OAAO,SAASG,uBACdC,OAA+B;IAE/B,MAAMC,IAAI;QAAE,GAAGD,OAAO;IAAC;IAEvB,MAAMJ,YAAYV,SAASc,QAAQE,SAAS;IAE5CD,EAAEL,SAAS,GAAGA;IAEdK,EAAEE,UAAU,GAAGf,KAAKE,WAAWU,QAAQP,WAAW;IAClDQ,EAAEG,UAAU,GAAGhB,KAAKY,QAAQE,SAAS;IACrCD,EAAEI,WAAW,GAAG,CAAC,CAAC,EAAEL,QAAQL,OAAO,CAAC,CAAC,EAAEC,WAAW;IAClDK,EAAEK,GAAG,GAAGd,QAAQS,EAAER,WAAW;IAC7BQ,EAAEJ,KAAK,GAAGH,WAAWM,QAAQL,OAAO,EAAEC,WAAWI,QAAQH,KAAK;IAE9D,IAAII,EAAEI,WAAW,CAACE,KAAK,CAAC,UAAU;QAChCN,EAAEO,mBAAmB,GAAGP,EAAEI,WAAW,CAACI,OAAO,CAAC,SAAS;IACzD,OAAO;QACLR,EAAEO,mBAAmB,GAAGP,EAAEI,WAAW,GAAG;IAC1C;IAEAJ,EAAES,eAAe,GAAGT,EAAEL,SAAS,CAACa,OAAO,CAAC,SAAS,IAAIA,OAAO,CAAC,QAAQ;IAErE,OAAO;QAAE,GAAGR,CAAC;QAAE,GAAGjB,MAAMY,UAAU;IAAC;AACrC;AAEA,OAAO,eAAee,iBAAiBC,IAAU,EAAEZ,OAA+B;IAChF,MAAMa,oBAAoBd,uBAAuBC;IAEjDjB,cAAc6B,MAAMC,kBAAkBV,UAAU,EAAEU,kBAAkBT,UAAU,EAAE;QAC9E,GAAGS,iBAAiB;IACtB;IAEA9B,cAAc6B,MAAMxB,KAAKE,WAAW,WAAWuB,kBAAkBT,UAAU,EAAE;QAC3E,GAAGS,iBAAiB;IACtB;IAEA5B,WAAW2B,MAAM,iBAAiB,CAACE;QACjC,IAAI,CAACA,MAAMC,UAAU,EAAE;YACrBD,MAAMC,UAAU,GAAG,EAAE;QACvB;QAEAD,MAAMC,UAAU,CAACC,IAAI,CAAC;YACpBC,MAAM,CAAC,EAAE,EAAEjB,QAAQE,SAAS,EAAE;QAChC;QAEA,OAAOY;IACT;IACA,MAAMhC,YAAY8B;AACpB;AAEA,eAAeD,iBAAiB"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnodes/cli",
|
|
3
3
|
"description": "Vnodes cli",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "robert.brightline+vnodes-prisma@gmail.com",
|
|
7
7
|
"name": "Robert Brightline",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@swc/helpers": "~0.5.18",
|
|
91
91
|
"commander": "^15.0.0",
|
|
92
92
|
"ejs": "^6.0.1",
|
|
93
|
-
"@vnodes/fs": "0.1.
|
|
93
|
+
"@vnodes/fs": "0.1.11"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/ejs": "^3.1.5"
|