create-nattyjs 0.0.1-beta.71 → 0.0.1-beta.72

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 (28) hide show
  1. package/index.js +92 -92
  2. package/package.json +1 -1
  3. package/src/const/template-definitions.js +76 -76
  4. package/src/const/version-registry.js +73 -73
  5. package/src/const/workspace-definitions.js +55 -55
  6. package/src/functions/cli-theme.js +81 -81
  7. package/src/functions/file-system.js +96 -96
  8. package/src/functions/package-manager.js +9 -9
  9. package/src/functions/package-name.js +12 -12
  10. package/src/functions/prompt-project-options.js +156 -156
  11. package/src/functions/render-package-jsons.js +98 -98
  12. package/src/functions/render-workspace.js +254 -254
  13. package/src/functions/scaffold-project.js +65 -65
  14. package/template-fullstack-angular/apps/api/package.json +8 -8
  15. package/template-fullstack-angular/apps/web/package.json +1 -1
  16. package/template-fullstack-astro/apps/api/package.json +8 -8
  17. package/template-fullstack-astro/apps/web/package.json +1 -1
  18. package/template-fullstack-next/apps/api/package.json +8 -8
  19. package/template-fullstack-next/apps/web/package.json +1 -1
  20. package/template-fullstack-nuxt/apps/api/package.json +8 -8
  21. package/template-fullstack-nuxt/apps/web/package.json +1 -1
  22. package/template-fullstack-react/apps/api/package.json +8 -8
  23. package/template-fullstack-react/apps/web/package.json +1 -1
  24. package/template-fullstack-sveltekit/apps/api/package.json +8 -8
  25. package/template-fullstack-sveltekit/apps/web/package.json +1 -1
  26. package/template-fullstack-vue/apps/api/package.json +8 -8
  27. package/template-fullstack-vue/apps/web/package.json +1 -1
  28. package/template-nattyjs-blank/package.json +8 -8
@@ -1,81 +1,81 @@
1
- import path from "path";
2
- import { bold, cyan, dim, green, yellow } from "kolorist";
3
-
4
- export function printIntro() {
5
- console.log("");
6
- console.log(bold(cyan("NattyJS Create")));
7
- console.log(dim("Scaffold a typed API or a fullstack workspace."));
8
- console.log("");
9
- }
10
-
11
- export function formatTemplateChoice(template) {
12
- const titleColor = template.id === "api-only" ? green : cyan;
13
- const badge = template.id === "api-only" ? green("API") : cyan("FULLSTACK");
14
- return {
15
- title: `${bold(titleColor(template.title))} ${dim(badge)}`,
16
- description: dim(template.description),
17
- };
18
- }
19
-
20
- export function formatLayoutChoice(layout) {
21
- const isRecommended = layout.recommended === true;
22
- const title = isRecommended
23
- ? `${bold(green(layout.title))} ${dim("(recommended)")}`
24
- : bold(cyan(layout.title));
25
-
26
- return {
27
- title,
28
- description: dim(layout.description),
29
- };
30
- }
31
-
32
- export function formatWorkspaceChoice(workspace) {
33
- const isRecommended = workspace.recommended === true;
34
- const title = isRecommended
35
- ? `${bold(yellow(workspace.title))} ${dim("(recommended)")}`
36
- : bold(cyan(workspace.title));
37
-
38
- return {
39
- title,
40
- description: dim(workspace.description),
41
- };
42
- }
43
-
44
- export function formatSuccessSummary({
45
- cwd,
46
- root,
47
- packageManager,
48
- template,
49
- workspace,
50
- includeExamples,
51
- }) {
52
- const activePackageManager = packageManager;
53
- const relativeRoot = root === cwd ? "." : path.relative(cwd, root);
54
- const isStandalone = workspace?.id === "standalone";
55
-
56
- console.log("");
57
- console.log(`${bold(green("Success"))} ${dim("Project scaffolded.")}`);
58
- console.log(`${bold("Location")} ${relativeRoot}`);
59
- console.log(`${bold("Template")} ${template.title}`);
60
- if (workspace) {
61
- console.log(`${bold("Layout")} ${workspace.title}`);
62
- }
63
- console.log(`${bold("Examples")} ${includeExamples ? "Yes" : "No"}`);
64
- console.log("");
65
- console.log(bold(cyan("Next Steps")));
66
- if (root !== cwd) {
67
- console.log(` cd ${relativeRoot}`);
68
- }
69
- if (activePackageManager === "yarn") {
70
- console.log(" yarn");
71
- console.log(" yarn dev");
72
- console.log("");
73
- return;
74
- }
75
- console.log(` ${activePackageManager} install`);
76
- if (isStandalone) {
77
- console.log(` ${activePackageManager} run install:apps`);
78
- }
79
- console.log(` ${activePackageManager} run dev`);
80
- console.log("");
81
- }
1
+ import path from "path";
2
+ import { bold, cyan, dim, green, yellow } from "kolorist";
3
+
4
+ export function printIntro() {
5
+ console.log("");
6
+ console.log(bold(cyan("NattyJS Create")));
7
+ console.log(dim("Scaffold a typed API or a fullstack workspace."));
8
+ console.log("");
9
+ }
10
+
11
+ export function formatTemplateChoice(template) {
12
+ const titleColor = template.id === "api-only" ? green : cyan;
13
+ const badge = template.id === "api-only" ? green("API") : cyan("FULLSTACK");
14
+ return {
15
+ title: `${bold(titleColor(template.title))} ${dim(badge)}`,
16
+ description: dim(template.description),
17
+ };
18
+ }
19
+
20
+ export function formatLayoutChoice(layout) {
21
+ const isRecommended = layout.recommended === true;
22
+ const title = isRecommended
23
+ ? `${bold(green(layout.title))} ${dim("(recommended)")}`
24
+ : bold(cyan(layout.title));
25
+
26
+ return {
27
+ title,
28
+ description: dim(layout.description),
29
+ };
30
+ }
31
+
32
+ export function formatWorkspaceChoice(workspace) {
33
+ const isRecommended = workspace.recommended === true;
34
+ const title = isRecommended
35
+ ? `${bold(yellow(workspace.title))} ${dim("(recommended)")}`
36
+ : bold(cyan(workspace.title));
37
+
38
+ return {
39
+ title,
40
+ description: dim(workspace.description),
41
+ };
42
+ }
43
+
44
+ export function formatSuccessSummary({
45
+ cwd,
46
+ root,
47
+ packageManager,
48
+ template,
49
+ workspace,
50
+ includeExamples,
51
+ }) {
52
+ const activePackageManager = packageManager;
53
+ const relativeRoot = root === cwd ? "." : path.relative(cwd, root);
54
+ const isStandalone = workspace?.id === "standalone";
55
+
56
+ console.log("");
57
+ console.log(`${bold(green("Success"))} ${dim("Project scaffolded.")}`);
58
+ console.log(`${bold("Location")} ${relativeRoot}`);
59
+ console.log(`${bold("Template")} ${template.title}`);
60
+ if (workspace) {
61
+ console.log(`${bold("Layout")} ${workspace.title}`);
62
+ }
63
+ console.log(`${bold("Examples")} ${includeExamples ? "Yes" : "No"}`);
64
+ console.log("");
65
+ console.log(bold(cyan("Next Steps")));
66
+ if (root !== cwd) {
67
+ console.log(` cd ${relativeRoot}`);
68
+ }
69
+ if (activePackageManager === "yarn") {
70
+ console.log(" yarn");
71
+ console.log(" yarn dev");
72
+ console.log("");
73
+ return;
74
+ }
75
+ console.log(` ${activePackageManager} install`);
76
+ if (isStandalone) {
77
+ console.log(` ${activePackageManager} run install:apps`);
78
+ }
79
+ console.log(` ${activePackageManager} run dev`);
80
+ console.log("");
81
+ }
@@ -1,96 +1,96 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- const renameFiles = {
5
- _gitignore: ".gitignore",
6
- };
7
-
8
- export function readJson(filePath) {
9
- if (!fs.existsSync(filePath)) {
10
- return undefined;
11
- }
12
-
13
- return JSON.parse(fs.readFileSync(filePath, "utf-8"));
14
- }
15
-
16
- export function isEmpty(dirPath) {
17
- const files = fs.readdirSync(dirPath);
18
- return files.length === 0 || (files.length === 1 && files[0] === ".git");
19
- }
20
-
21
- export function emptyDir(dir) {
22
- if (!fs.existsSync(dir)) {
23
- return;
24
- }
25
-
26
- for (const file of fs.readdirSync(dir)) {
27
- const absolutePath = path.resolve(dir, file);
28
- if (fs.lstatSync(absolutePath).isDirectory()) {
29
- emptyDir(absolutePath);
30
- fs.rmdirSync(absolutePath);
31
- } else {
32
- fs.unlinkSync(absolutePath);
33
- }
34
- }
35
- }
36
-
37
- export function copy(src, dest) {
38
- const stat = fs.statSync(src);
39
- if (stat.isDirectory()) {
40
- copyDir(src, dest);
41
- return;
42
- }
43
-
44
- fs.copyFileSync(src, dest);
45
- }
46
-
47
- export function copyDir(srcDir, destDir) {
48
- fs.mkdirSync(destDir, { recursive: true });
49
- for (const file of fs.readdirSync(srcDir)) {
50
- const srcFile = path.resolve(srcDir, file);
51
- const destFile = path.resolve(destDir, file);
52
- copy(srcFile, destFile);
53
- }
54
- }
55
-
56
- export function shouldSkipTemplateFile(relativePath, template, includeExamples) {
57
- if (includeExamples) {
58
- return false;
59
- }
60
-
61
- const excludedPaths = template.exampleExcludedPaths || [];
62
- return excludedPaths.some((excludedPath) => {
63
- return relativePath === excludedPath || relativePath.startsWith(`${excludedPath}${path.sep}`);
64
- });
65
- }
66
-
67
- export function copyTemplateContents(templateDir, root, template, includeExamples) {
68
- const entries = fs.readdirSync(templateDir);
69
- for (const entry of entries) {
70
- if (entry === "package.json") {
71
- continue;
72
- }
73
-
74
- if (entry === template.exampleOverlayDir) {
75
- continue;
76
- }
77
-
78
- if (shouldSkipTemplateFile(entry, template, includeExamples)) {
79
- continue;
80
- }
81
-
82
- const sourcePath = path.join(templateDir, entry);
83
- const targetPath = renameFiles[entry]
84
- ? path.join(root, renameFiles[entry])
85
- : path.join(root, entry);
86
-
87
- copy(sourcePath, targetPath);
88
- }
89
-
90
- if (includeExamples && template.exampleOverlayDir) {
91
- const overlayDir = path.join(templateDir, template.exampleOverlayDir);
92
- if (fs.existsSync(overlayDir)) {
93
- copyDir(overlayDir, root);
94
- }
95
- }
96
- }
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ const renameFiles = {
5
+ _gitignore: ".gitignore",
6
+ };
7
+
8
+ export function readJson(filePath) {
9
+ if (!fs.existsSync(filePath)) {
10
+ return undefined;
11
+ }
12
+
13
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
14
+ }
15
+
16
+ export function isEmpty(dirPath) {
17
+ const files = fs.readdirSync(dirPath);
18
+ return files.length === 0 || (files.length === 1 && files[0] === ".git");
19
+ }
20
+
21
+ export function emptyDir(dir) {
22
+ if (!fs.existsSync(dir)) {
23
+ return;
24
+ }
25
+
26
+ for (const file of fs.readdirSync(dir)) {
27
+ const absolutePath = path.resolve(dir, file);
28
+ if (fs.lstatSync(absolutePath).isDirectory()) {
29
+ emptyDir(absolutePath);
30
+ fs.rmdirSync(absolutePath);
31
+ } else {
32
+ fs.unlinkSync(absolutePath);
33
+ }
34
+ }
35
+ }
36
+
37
+ export function copy(src, dest) {
38
+ const stat = fs.statSync(src);
39
+ if (stat.isDirectory()) {
40
+ copyDir(src, dest);
41
+ return;
42
+ }
43
+
44
+ fs.copyFileSync(src, dest);
45
+ }
46
+
47
+ export function copyDir(srcDir, destDir) {
48
+ fs.mkdirSync(destDir, { recursive: true });
49
+ for (const file of fs.readdirSync(srcDir)) {
50
+ const srcFile = path.resolve(srcDir, file);
51
+ const destFile = path.resolve(destDir, file);
52
+ copy(srcFile, destFile);
53
+ }
54
+ }
55
+
56
+ export function shouldSkipTemplateFile(relativePath, template, includeExamples) {
57
+ if (includeExamples) {
58
+ return false;
59
+ }
60
+
61
+ const excludedPaths = template.exampleExcludedPaths || [];
62
+ return excludedPaths.some((excludedPath) => {
63
+ return relativePath === excludedPath || relativePath.startsWith(`${excludedPath}${path.sep}`);
64
+ });
65
+ }
66
+
67
+ export function copyTemplateContents(templateDir, root, template, includeExamples) {
68
+ const entries = fs.readdirSync(templateDir);
69
+ for (const entry of entries) {
70
+ if (entry === "package.json") {
71
+ continue;
72
+ }
73
+
74
+ if (entry === template.exampleOverlayDir) {
75
+ continue;
76
+ }
77
+
78
+ if (shouldSkipTemplateFile(entry, template, includeExamples)) {
79
+ continue;
80
+ }
81
+
82
+ const sourcePath = path.join(templateDir, entry);
83
+ const targetPath = renameFiles[entry]
84
+ ? path.join(root, renameFiles[entry])
85
+ : path.join(root, entry);
86
+
87
+ copy(sourcePath, targetPath);
88
+ }
89
+
90
+ if (includeExamples && template.exampleOverlayDir) {
91
+ const overlayDir = path.join(templateDir, template.exampleOverlayDir);
92
+ if (fs.existsSync(overlayDir)) {
93
+ copyDir(overlayDir, root);
94
+ }
95
+ }
96
+ }
@@ -1,9 +1,9 @@
1
- export function pkgFromUserAgent(userAgent) {
2
- if (!userAgent) {
3
- return undefined;
4
- }
5
-
6
- const pkgSpec = userAgent.split(" ")[0];
7
- const [name, version] = pkgSpec.split("/");
8
- return { name, version };
9
- }
1
+ export function pkgFromUserAgent(userAgent) {
2
+ if (!userAgent) {
3
+ return undefined;
4
+ }
5
+
6
+ const pkgSpec = userAgent.split(" ")[0];
7
+ const [name, version] = pkgSpec.split("/");
8
+ return { name, version };
9
+ }
@@ -1,12 +1,12 @@
1
- export function isValidPackageName(projectName) {
2
- return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
3
- }
4
-
5
- export function toValidPackageName(projectName) {
6
- return projectName
7
- .trim()
8
- .toLowerCase()
9
- .replace(/\s+/g, "-")
10
- .replace(/^[._]/, "")
11
- .replace(/[^a-z0-9-~]+/g, "-");
12
- }
1
+ export function isValidPackageName(projectName) {
2
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
3
+ }
4
+
5
+ export function toValidPackageName(projectName) {
6
+ return projectName
7
+ .trim()
8
+ .toLowerCase()
9
+ .replace(/\s+/g, "-")
10
+ .replace(/^[._]/, "")
11
+ .replace(/[^a-z0-9-~]+/g, "-");
12
+ }