@vnodes/cli 0.1.9 → 0.1.10
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/rm/rm.d.ts +1 -1
- 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 +6 -2
- package/dist/cli/suffix/suffix.d.ts.map +1 -1
- package/dist/cli/suffix/suffix.js +9 -5
- package/dist/cli/suffix/suffix.js.map +1 -1
- package/dist/cli/workspace/workspace.d.ts +2 -2
- package/dist/cli/workspace/workspace.d.ts.map +1 -1
- package/dist/cli/workspace/workspace.js +19 -23
- package/dist/cli/workspace/workspace.js.map +1 -1
- 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/project.d.ts +1 -0
- package/dist/generators/project/project.d.ts.map +1 -1
- package/dist/generators/project/project.js +13 -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/rm/rm.d.ts
CHANGED
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;AAIpC;;;;;;;;GAQG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../src/cli/rm/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;;;;;;;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 { 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
1
|
import { 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;AAIpC
|
|
1
|
+
{"version":3,"file":"suffix.d.ts","sourceRoot":"","sources":["../../../src/cli/suffix/suffix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,QAsBtC"}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { readdirSync, renameSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
/**
|
|
4
|
-
* Suffix file/files recursive
|
|
4
|
+
* Suffix file/files recursive (optional)
|
|
5
5
|
*
|
|
6
6
|
* ### Example
|
|
7
7
|
* ````sh
|
|
8
|
-
*
|
|
8
|
+
* # Add .template suffix
|
|
9
|
+
* vnodes suffix --s .template -r
|
|
10
|
+
*
|
|
11
|
+
* # Remove the .template suffix
|
|
12
|
+
* vnodes suffix --s .template -r -u
|
|
9
13
|
* ````
|
|
10
14
|
* @param command main command instance
|
|
11
15
|
*/ export function suffix(command) {
|
|
12
|
-
command.command('suffix').option('-u, --undo', '
|
|
13
|
-
const
|
|
16
|
+
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 })=>{
|
|
17
|
+
const absolutePaths = readdirSync('', {
|
|
14
18
|
recursive: !!recursive,
|
|
15
19
|
withFileTypes: true
|
|
16
20
|
}).filter((e)=>e.isFile()).map((e)=>join('./', e.parentPath, e.name));
|
|
17
21
|
const createNewFilepath = (filePath)=>{
|
|
18
22
|
return undo ? filePath.replace(new RegExp(`${suffix}$`), '') : `${filePath}${suffix}`;
|
|
19
23
|
};
|
|
20
|
-
for (const filePath of
|
|
24
|
+
for (const filePath of absolutePaths){
|
|
21
25
|
renameSync(filePath, createNewFilepath(filePath));
|
|
22
26
|
}
|
|
23
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/suffix/suffix.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readdirSync, renameSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Suffix file/files recursive\n *\n * ### Example\n * ````sh\n * vnodes suffix --
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/suffix/suffix.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readdirSync, renameSync } from 'node:fs';\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 absolutePaths = readdirSync('', {\n recursive: !!recursive,\n withFileTypes: true,\n })\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":["readdirSync","renameSync","join","suffix","command","option","requiredOption","action","recursive","undo","absolutePaths","withFileTypes","filter","e","isFile","map","parentPath","name","createNewFilepath","filePath","replace","RegExp"],"mappings":"AACA,SAASA,WAAW,EAAEC,UAAU,QAAQ,UAAU;AAClD,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,gBAAgBV,YAAY,IAAI;YACpCQ,WAAW,CAAC,CAACA;YACbG,eAAe;QACjB,GACGC,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,IACtBC,GAAG,CAAC,CAACF,IAAMX,KAAK,MAAMW,EAAEG,UAAU,EAAEH,EAAEI,IAAI;QAE7C,MAAMC,oBAAoB,CAACC;YACzB,OAAOV,OAAOU,SAASC,OAAO,CAAC,IAAIC,OAAO,GAAGlB,OAAO,CAAC,CAAC,GAAG,MAAM,GAAGgB,WAAWhB,QAAQ;QACvF;QAEA,KAAK,MAAMgB,YAAYT,cAAe;YACpCT,WAAWkB,UAAUD,kBAAkBC;QACzC;IACF;AACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { 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":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/cli/workspace/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCpC;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,QASzC"}
|
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
1
|
+
import { copyFilesGenerator, filesGenerator, readTextFile, writeTextFile } from '@vnodes/fs';
|
|
2
|
+
import { basename, dirname, join, relative } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { readdir } from 'node:fs/promises';
|
|
5
|
-
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
4
|
import ejs from 'ejs';
|
|
7
5
|
import { names } from '@nx/devkit';
|
|
6
|
+
import { mkdir } from 'node:fs/promises';
|
|
7
|
+
import { cwd } from 'node:process';
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
async function geneateFiles(name) {
|
|
10
|
-
|
|
10
|
+
const removeTemplateSuffix = (filePath)=>{
|
|
11
11
|
return filePath.slice(0, -'.template'.length);
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
const copyFilesGeneartor = copyFilesGenerator(join(__dirname, 'files'), join(name), removeTemplateSuffix);
|
|
14
|
+
for await (const entry of copyFilesGeneartor){
|
|
15
|
+
console.log(`[ Created ] ${entry}`);
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
async function generateTemplates(name) {
|
|
15
19
|
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), {
|
|
20
|
+
const templateFiles = filesGenerator(templateRootDir);
|
|
21
|
+
for await (const filePath of templateFiles){
|
|
22
|
+
const templateFilePath = join(filePath, basename(filePath));
|
|
23
|
+
const templateFileContent = await readTextFile(templateFilePath);
|
|
24
|
+
const targetTemplateFilePath = relative(cwd(), templateFilePath).slice(0, -'.ejs'.length);
|
|
25
|
+
await mkdir(dirname(targetTemplateFilePath), {
|
|
28
26
|
recursive: true
|
|
29
27
|
});
|
|
30
28
|
const renderedContent = ejs.render(templateFileContent, {
|
|
31
29
|
...names(name),
|
|
32
30
|
email: `${name}@${name}.com`
|
|
33
31
|
});
|
|
34
|
-
|
|
35
|
-
encoding: 'utf-8'
|
|
36
|
-
});
|
|
32
|
+
await writeTextFile(targetTemplateFilePath, renderedContent);
|
|
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 { copyFilesGenerator, filesGenerator, readTextFile, writeTextFile } from '@vnodes/fs';\nimport { Command } from 'commander';\nimport { basename, dirname, join, relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport ejs from 'ejs';\nimport { names } from '@nx/devkit';\nimport { mkdir } from 'node:fs/promises';\nimport { cwd } from 'node:process';\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(join(__dirname, 'files'), join(name), removeTemplateSuffix);\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 templateFilePath = join(filePath, basename(filePath));\n const templateFileContent = await readTextFile(templateFilePath);\n const targetTemplateFilePath = relative(cwd(), templateFilePath).slice(0, -'.ejs'.length);\n\n await mkdir(dirname(targetTemplateFilePath), { recursive: true });\n const renderedContent = ejs.render(templateFileContent, { ...names(name), email: `${name}@${name}.com` });\n await writeTextFile(targetTemplateFilePath, renderedContent);\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":["copyFilesGenerator","filesGenerator","readTextFile","writeTextFile","basename","dirname","join","relative","fileURLToPath","ejs","names","mkdir","cwd","__dirname","url","geneateFiles","name","removeTemplateSuffix","filePath","slice","length","copyFilesGeneartor","entry","console","log","generateTemplates","templateRootDir","templateFiles","templateFilePath","templateFileContent","targetTemplateFilePath","recursive","renderedContent","render","email","workspace","command","description","requiredOption","action"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,cAAc,EAAEC,YAAY,EAAEC,aAAa,QAAQ,aAAa;AAE7F,SAASC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAC9D,SAASC,aAAa,QAAQ,WAAW;AACzC,OAAOC,SAAS,MAAM;AACtB,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,KAAK,QAAQ,mBAAmB;AACzC,SAASC,GAAG,QAAQ,eAAe;AAEnC,MAAMC,YAAYR,QAAQG,cAAc,YAAYM,GAAG;AAEvD,eAAeC,aAAaC,IAAY;IACtC,MAAMC,uBAAuB,CAACC;QAC5B,OAAOA,SAASC,KAAK,CAAC,GAAG,CAAC,YAAYC,MAAM;IAC9C;IACA,MAAMC,qBAAqBrB,mBAAmBM,KAAKO,WAAW,UAAUP,KAAKU,OAAOC;IAEpF,WAAW,MAAMK,SAASD,mBAAoB;QAC5CE,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAEF,OAAO;IACpC;AACF;AAEA,eAAeG,kBAAkBT,IAAY;IAC3C,MAAMU,kBAAkBpB,KAAKO,WAAW;IACxC,MAAMc,gBAAgB1B,eAAeyB;IAErC,WAAW,MAAMR,YAAYS,cAAe;QAC1C,MAAMC,mBAAmBtB,KAAKY,UAAUd,SAASc;QACjD,MAAMW,sBAAsB,MAAM3B,aAAa0B;QAC/C,MAAME,yBAAyBvB,SAASK,OAAOgB,kBAAkBT,KAAK,CAAC,GAAG,CAAC,OAAOC,MAAM;QAExF,MAAMT,MAAMN,QAAQyB,yBAAyB;YAAEC,WAAW;QAAK;QAC/D,MAAMC,kBAAkBvB,IAAIwB,MAAM,CAACJ,qBAAqB;YAAE,GAAGnB,MAAMM,KAAK;YAAEkB,OAAO,GAAGlB,KAAK,CAAC,EAAEA,KAAK,IAAI,CAAC;QAAC;QACvG,MAAMb,cAAc2B,wBAAwBE;IAC9C;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASG,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"}
|
|
@@ -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] })],
|
|
@@ -9,6 +9,7 @@ export type NormalizedProjectGeneratorOptions = ProjectGeneratorSchema & {
|
|
|
9
9
|
targetRoot: string;
|
|
10
10
|
tag: string;
|
|
11
11
|
workspaceVersion: string;
|
|
12
|
+
databaseProjectName: string;
|
|
12
13
|
} & ReturnType<typeof names>;
|
|
13
14
|
export declare function normalizeProjectSchema(options: ProjectGeneratorSchema): NormalizedProjectGeneratorOptions;
|
|
14
15
|
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,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,sBAAsB,GAAG,iCAAiC,CAmBzG;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,iBAqBjF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -23,18 +23,23 @@ 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
|
+
}
|
|
36
41
|
return {
|
|
37
|
-
...
|
|
42
|
+
...n,
|
|
38
43
|
...names(shortName)
|
|
39
44
|
};
|
|
40
45
|
}
|
|
@@ -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';\nimport { fileURLToPath } from 'node:url';\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} & ReturnType<typeof names>;\n\nexport function normalizeProjectSchema(options: ProjectGeneratorSchema): NormalizedProjectGeneratorOptions {\n const
|
|
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';\nimport { fileURLToPath } from 'node:url';\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} & ReturnType<typeof names>;\n\nexport function normalizeProjectSchema(options: ProjectGeneratorSchema): NormalizedProjectGeneratorOptions {\n const n = { ...options } as NormalizedProjectGeneratorOptions;\n\n const shortName = basename(options.directory);\n\n n.shortName = shortName;\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 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, { ...normalizedOptions });\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","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;AAEpD,SAASC,aAAa,QAAQ,WAAW;AAEzC,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;AAYA,OAAO,SA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Y6B;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.10",
|
|
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.10"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/ejs": "^3.1.5"
|