create-vatts-app 1.0.0 → 1.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.
- package/dist/{createApp/cli.js → cli.js} +25 -4
- package/dist/{createApp/createApp.js → createApp.js} +11 -9
- package/dist/{createApp/packageJson.d.ts → packageJson.d.ts} +1 -1
- package/dist/{createApp/packageJson.js → packageJson.js} +12 -4
- package/dist/steps/createExampleRoutes.d.ts +2 -0
- package/dist/steps/createExampleRoutes.js +53 -0
- package/dist/steps/createProject.d.ts +2 -0
- package/dist/steps/createProject.js +55 -0
- package/dist/steps/createProjectStructure.d.ts +2 -0
- package/dist/steps/createProjectStructure.js +56 -0
- package/dist/steps/index.d.ts +7 -0
- package/dist/steps/index.js +43 -0
- package/dist/steps/installDependencies.d.ts +2 -0
- package/dist/steps/installDependencies.js +63 -0
- package/dist/steps/setupTailwind.d.ts +2 -0
- package/dist/steps/setupTailwind.js +49 -0
- package/dist/steps/writeTsConfig.d.ts +2 -0
- package/dist/steps/writeTsConfig.js +48 -0
- package/dist/steps/writeVattsConfig.d.ts +2 -0
- package/dist/steps/writeVattsConfig.js +42 -0
- package/dist/summary.d.ts +2 -0
- package/dist/summary.js +45 -0
- package/dist/templates.d.ts +11 -0
- package/dist/{createApp/templates.js → templates.js} +72 -11
- package/dist/{createApp/types.d.ts → types.d.ts} +4 -0
- package/package.json +2 -2
- package/dist/createApp/index.d.ts +0 -1
- package/dist/createApp/index.js +0 -17
- package/dist/createApp/steps.d.ts +0 -9
- package/dist/createApp/steps.js +0 -160
- package/dist/createApp/templates.d.ts +0 -10
- /package/dist/{createApp/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{createApp/createApp.d.ts → createApp.d.ts} +0 -0
- /package/dist/{createApp/fs.d.ts → fs.d.ts} +0 -0
- /package/dist/{createApp/fs.js → fs.js} +0 -0
- /package/dist/{createApp/install.d.ts → install.d.ts} +0 -0
- /package/dist/{createApp/install.js → install.js} +0 -0
- /package/dist/{createApp/types.js → types.js} +0 -0
- /package/dist/{createApp/validate.d.ts → validate.d.ts} +0 -0
- /package/dist/{createApp/validate.js → validate.js} +0 -0
|
@@ -48,27 +48,41 @@ function parseArgs(argv) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
async function promptForMissingOptions(opts) {
|
|
51
|
-
|
|
51
|
+
let appName = opts.appName;
|
|
52
|
+
if (appName === undefined) {
|
|
53
|
+
appName = await console_1.default.ask("What is the name of your app?", "my-vatts-app");
|
|
54
|
+
console.log(" ");
|
|
55
|
+
}
|
|
56
|
+
let typescript = opts.typeScript;
|
|
57
|
+
if (typescript === undefined) {
|
|
58
|
+
typescript = await console_1.default.confirm("Do you want to use typescript?", true);
|
|
59
|
+
console.log(" ");
|
|
60
|
+
}
|
|
52
61
|
let tailwind = opts.tailwind;
|
|
53
62
|
if (tailwind === undefined) {
|
|
54
63
|
tailwind = await console_1.default.confirm("Do you want to include Tailwind CSS?", true);
|
|
64
|
+
console.log(" ");
|
|
55
65
|
}
|
|
56
66
|
let examples = opts.examples;
|
|
57
67
|
if (examples === undefined) {
|
|
58
68
|
examples = await console_1.default.confirm("Do you want to include example routes?", true);
|
|
69
|
+
console.log(" ");
|
|
59
70
|
}
|
|
60
|
-
let
|
|
61
|
-
if (
|
|
62
|
-
|
|
71
|
+
let pathRouter = opts.pathRouter;
|
|
72
|
+
if (pathRouter === undefined) {
|
|
73
|
+
pathRouter = await console_1.default.confirm("Do you want to use path router?", false);
|
|
74
|
+
console.log(" ");
|
|
63
75
|
}
|
|
64
76
|
let moduleAlias = opts.moduleAlias;
|
|
65
77
|
if (moduleAlias === undefined) {
|
|
66
78
|
moduleAlias = await console_1.default.confirm("Do you want to set a module alias?", true);
|
|
79
|
+
console.log(" ");
|
|
67
80
|
}
|
|
68
81
|
let alias = opts.alias;
|
|
69
82
|
if (moduleAlias) {
|
|
70
83
|
if (alias === undefined) {
|
|
71
84
|
alias = await console_1.default.ask("Which alias do you want to set?", "@/");
|
|
85
|
+
console.log(" ");
|
|
72
86
|
}
|
|
73
87
|
alias = normalizeAliasPrefix(alias);
|
|
74
88
|
}
|
|
@@ -76,6 +90,11 @@ async function promptForMissingOptions(opts) {
|
|
|
76
90
|
// keep a stable value even when disabled
|
|
77
91
|
alias = "@/";
|
|
78
92
|
}
|
|
93
|
+
let install = opts.install;
|
|
94
|
+
if (install === undefined) {
|
|
95
|
+
install = await console_1.default.confirm("Do you want to install dependencies?", true);
|
|
96
|
+
console.log(" ");
|
|
97
|
+
}
|
|
79
98
|
return {
|
|
80
99
|
appName,
|
|
81
100
|
tailwind,
|
|
@@ -83,5 +102,7 @@ async function promptForMissingOptions(opts) {
|
|
|
83
102
|
install,
|
|
84
103
|
moduleAlias,
|
|
85
104
|
alias,
|
|
105
|
+
pathRouter,
|
|
106
|
+
typeScript: typescript
|
|
86
107
|
};
|
|
87
108
|
}
|
|
@@ -37,10 +37,11 @@ exports.createAppFromArgv = createAppFromArgv;
|
|
|
37
37
|
exports.createApp = createApp;
|
|
38
38
|
const cli_1 = require("./cli");
|
|
39
39
|
const steps_1 = require("./steps");
|
|
40
|
+
const summary_1 = require("./summary");
|
|
40
41
|
const path = __importStar(require("node:path"));
|
|
41
42
|
const validate_1 = require("./validate");
|
|
42
43
|
function resolveOwnPackageJson() {
|
|
43
|
-
const pkgPath = path.resolve(__dirname, "..", "
|
|
44
|
+
const pkgPath = path.resolve(__dirname, "..", "package.json");
|
|
44
45
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
45
46
|
return require(pkgPath);
|
|
46
47
|
}
|
|
@@ -65,14 +66,15 @@ async function createApp(options) {
|
|
|
65
66
|
moduleAlias: resolved.alias,
|
|
66
67
|
vattsVersion: ownPkg.version,
|
|
67
68
|
packageJson: {},
|
|
69
|
+
pathRouter: resolved.pathRouter,
|
|
70
|
+
typeScript: resolved.typeScript
|
|
68
71
|
};
|
|
69
72
|
console.clear();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(0, steps_1.printSummary)(ctx);
|
|
73
|
+
for (const step of steps_1.steps) {
|
|
74
|
+
if (step.condition?.(ctx) === false) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
await step.action(ctx);
|
|
78
|
+
}
|
|
79
|
+
(0, summary_1.printSummary)(ctx);
|
|
78
80
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CreateAppContext } from "./types";
|
|
2
|
-
export declare function buildPackageJson(ctx: Pick<CreateAppContext, "appName" | "vattsVersion" | "willTailwind">): Promise<any>;
|
|
2
|
+
export declare function buildPackageJson(ctx: Pick<CreateAppContext, "appName" | "vattsVersion" | "willTailwind" | "typeScript">): Promise<any>;
|
|
@@ -28,16 +28,24 @@ async function buildPackageJson(ctx) {
|
|
|
28
28
|
dev: "vatts dev",
|
|
29
29
|
},
|
|
30
30
|
dependencies: {
|
|
31
|
-
vatts:
|
|
31
|
+
vatts: `^${version}`,
|
|
32
32
|
react: "^19.2.3",
|
|
33
|
-
"react-dom": "^19.2.3"
|
|
34
|
-
"ts-node": "^10.9.2",
|
|
33
|
+
"react-dom": "^19.2.3"
|
|
35
34
|
},
|
|
36
35
|
devDependencies: {
|
|
37
36
|
"@types/react": "^19.2.8",
|
|
38
|
-
typescript: "^5.9.3",
|
|
39
37
|
},
|
|
40
38
|
};
|
|
39
|
+
if (ctx.typeScript) {
|
|
40
|
+
packageJson.devDependencies = {
|
|
41
|
+
...packageJson.devDependencies,
|
|
42
|
+
typescript: "^5.9.3",
|
|
43
|
+
};
|
|
44
|
+
packageJson.dependencies = {
|
|
45
|
+
...packageJson.dependencies,
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
41
49
|
if (ctx.willTailwind) {
|
|
42
50
|
packageJson.dependencies = {
|
|
43
51
|
...packageJson.dependencies,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createExampleRoutes = createExampleRoutes;
|
|
40
|
+
const console_1 = __importDefault(require("vatts/console"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const fs_1 = require("../fs");
|
|
43
|
+
const templates_1 = require("../templates");
|
|
44
|
+
async function createExampleRoutes(ctx) {
|
|
45
|
+
const dynamic = console_1.default.dynamicLine("Creating example routes...");
|
|
46
|
+
let pathResolve = path.join(ctx.rootDir, "src", "web", "routes", `index.${ctx.typeScript ? 'tsx' : 'jsx'}`);
|
|
47
|
+
if (ctx.pathRouter) {
|
|
48
|
+
pathResolve = path.join(ctx.rootDir, "src", "web", `page.${ctx.typeScript ? 'tsx' : 'jsx'}`);
|
|
49
|
+
}
|
|
50
|
+
(0, fs_1.writeFile)(pathResolve, (0, templates_1.webIndexRouteTemplate)(ctx.willTailwind, ctx.pathRouter, ctx.typeScript));
|
|
51
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "backend", "routes", `Example.${ctx.typeScript ? 'ts' : 'js'}`), (0, templates_1.backendExampleRouteTemplate)(ctx.typeScript));
|
|
52
|
+
dynamic.end("Example routes created.");
|
|
53
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createProject = createProject;
|
|
40
|
+
const console_1 = __importDefault(require("vatts/console"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const fs_1 = require("../fs");
|
|
43
|
+
const packageJson_1 = require("../packageJson");
|
|
44
|
+
async function createProject(ctx) {
|
|
45
|
+
const dynamic = console_1.default.dynamicLine("Creating your Vatts.js app...");
|
|
46
|
+
(0, fs_1.ensureDir)(ctx.rootDir);
|
|
47
|
+
ctx.packageJson = await (0, packageJson_1.buildPackageJson)({
|
|
48
|
+
appName: ctx.appName,
|
|
49
|
+
vattsVersion: ctx.vattsVersion,
|
|
50
|
+
willTailwind: ctx.willTailwind,
|
|
51
|
+
typeScript: ctx.typeScript
|
|
52
|
+
});
|
|
53
|
+
(0, fs_1.writeJson)(path.join(ctx.rootDir, "package.json"), ctx.packageJson);
|
|
54
|
+
dynamic.end("Created project directory and package.json");
|
|
55
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createProjectStructure = createProjectStructure;
|
|
40
|
+
const console_1 = __importDefault(require("vatts/console"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const fs_1 = require("../fs");
|
|
43
|
+
const templates_1 = require("../templates");
|
|
44
|
+
async function createProjectStructure(ctx) {
|
|
45
|
+
const dynamic = console_1.default.dynamicLine("Creating project structure...");
|
|
46
|
+
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "backend", "routes"));
|
|
47
|
+
if (!ctx.pathRouter) {
|
|
48
|
+
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web", "routes"));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web"));
|
|
52
|
+
}
|
|
53
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", "globals.css"), (0, templates_1.globalsCssTemplate)(ctx.willTailwind));
|
|
54
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", `layout.${ctx.typeScript ? 'tsx' : 'jsx'}`), ctx.typeScript ? (0, templates_1.layoutTsxTemplate)() : (0, templates_1.layoutJsxTemplate)());
|
|
55
|
+
dynamic.end("Created project structure");
|
|
56
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.steps = void 0;
|
|
4
|
+
const createProject_1 = require("./createProject");
|
|
5
|
+
const createProjectStructure_1 = require("./createProjectStructure");
|
|
6
|
+
const writeVattsConfig_1 = require("./writeVattsConfig");
|
|
7
|
+
const writeTsConfig_1 = require("./writeTsConfig");
|
|
8
|
+
const setupTailwind_1 = require("./setupTailwind");
|
|
9
|
+
const createExampleRoutes_1 = require("./createExampleRoutes");
|
|
10
|
+
const installDependencies_1 = require("./installDependencies");
|
|
11
|
+
exports.steps = [
|
|
12
|
+
{
|
|
13
|
+
label: "Creating project directory and package.json",
|
|
14
|
+
action: createProject_1.createProject,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: "Creating project structure",
|
|
18
|
+
action: createProjectStructure_1.createProjectStructure,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Writing vatts.config.ts",
|
|
22
|
+
action: writeVattsConfig_1.writeVattsConfig,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Initializing TypeScript configuration",
|
|
26
|
+
action: writeTsConfig_1.writeTsConfig,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "Setting up Tailwind CSS",
|
|
30
|
+
action: setupTailwind_1.setupTailwind,
|
|
31
|
+
condition: (ctx) => ctx.willTailwind,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Creating example routes",
|
|
35
|
+
action: createExampleRoutes_1.createExampleRoutes,
|
|
36
|
+
condition: (ctx) => ctx.willRouteExample,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Installing dependencies",
|
|
40
|
+
action: installDependencies_1.installDependencies,
|
|
41
|
+
condition: (ctx) => ctx.willInstallDependencies,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.installDependencies = installDependencies;
|
|
37
|
+
const console_1 = __importStar(require("vatts/console"));
|
|
38
|
+
const install_1 = require("../install");
|
|
39
|
+
async function installDependencies(ctx) {
|
|
40
|
+
const dynamic = console_1.default.dynamicLine("Installing dependencies...");
|
|
41
|
+
console.log(`\nInstalling dependencies:\n${ctx.packageJson.dependencies
|
|
42
|
+
? Object.keys(ctx.packageJson.dependencies)
|
|
43
|
+
.map((dep) => ` - ${console_1.Colors.FgCyan}${dep}${console_1.Colors.Reset}`)
|
|
44
|
+
.join("\n")
|
|
45
|
+
: ""}\n\nInstalling devDependencies:\n${ctx.packageJson.devDependencies
|
|
46
|
+
? Object.keys(ctx.packageJson.devDependencies)
|
|
47
|
+
.map((dep) => ` - ${console_1.Colors.FgCyan}${dep}${console_1.Colors.Reset}`)
|
|
48
|
+
.join("\n")
|
|
49
|
+
: ""}\n`);
|
|
50
|
+
const spinnerFrames = ["|", "/", "-", "\\"];
|
|
51
|
+
let frameIndex = 0;
|
|
52
|
+
const spinner = setInterval(() => {
|
|
53
|
+
dynamic.update(`${console_1.Colors.FgGreen}${spinnerFrames[frameIndex]}${console_1.Colors.Reset} Installing...`);
|
|
54
|
+
frameIndex = (frameIndex + 1) % spinnerFrames.length;
|
|
55
|
+
}, 100);
|
|
56
|
+
try {
|
|
57
|
+
await (0, install_1.npmInstall)(ctx.rootDir);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearInterval(spinner);
|
|
61
|
+
}
|
|
62
|
+
dynamic.end("Dependencies installed.");
|
|
63
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setupTailwind = setupTailwind;
|
|
40
|
+
const console_1 = __importDefault(require("vatts/console"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const fs_1 = require("../fs");
|
|
43
|
+
const templates_1 = require("../templates");
|
|
44
|
+
async function setupTailwind(ctx) {
|
|
45
|
+
const dynamic = console_1.default.dynamicLine("Setting up Tailwind CSS...");
|
|
46
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "postcss.config.js"), (0, templates_1.postcssConfigTemplate)());
|
|
47
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "tailwind.config.js"), (0, templates_1.tailwindConfigTemplate)());
|
|
48
|
+
dynamic.end("Tailwind CSS setup complete.");
|
|
49
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.writeTsConfig = writeTsConfig;
|
|
40
|
+
const console_1 = __importDefault(require("vatts/console"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const fs_1 = require("../fs");
|
|
43
|
+
const templates_1 = require("../templates");
|
|
44
|
+
async function writeTsConfig(ctx) {
|
|
45
|
+
const dynamic = console_1.default.dynamicLine("Initializing TypeScript configuration...");
|
|
46
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, "tsconfig.json"), (0, templates_1.tsconfigTemplate)(ctx.willUseModuleAlias ? { moduleAlias: ctx.moduleAlias } : { moduleAlias: false }));
|
|
47
|
+
dynamic.end("TypeScript configuration initialized.");
|
|
48
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.writeVattsConfig = writeVattsConfig;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const fs_1 = require("../fs");
|
|
39
|
+
const templates_1 = require("../templates");
|
|
40
|
+
async function writeVattsConfig(ctx) {
|
|
41
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, `vatts.config.${ctx.typeScript ? 'ts' : 'js'}`), (0, templates_1.vattsConfigTemplate)(ctx.typeScript, ctx.pathRouter));
|
|
42
|
+
}
|
package/dist/summary.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printSummary = printSummary;
|
|
4
|
+
const console_1 = require("vatts/console");
|
|
5
|
+
function printSummary(ctx) {
|
|
6
|
+
console.clear();
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const time = now.toLocaleTimeString("pt-BR", { hour12: false });
|
|
9
|
+
const timer = ` ${console_1.Colors.FgGray}${time}${console_1.Colors.Reset} `;
|
|
10
|
+
const label = console_1.Colors.FgGray;
|
|
11
|
+
const cmd = console_1.Colors.Bright + console_1.Colors.FgCyan;
|
|
12
|
+
const ok = console_1.Colors.FgGreen;
|
|
13
|
+
const dim = console_1.Colors.Dim;
|
|
14
|
+
const bright = console_1.Colors.Bright;
|
|
15
|
+
const nodeVersion = process.version;
|
|
16
|
+
const platform = process.platform;
|
|
17
|
+
console.log("");
|
|
18
|
+
console.log(`${timer}${bright}${console_1.Colors.FgCyan}Vatts.js${console_1.Colors.Reset} ${dim}v${ctx.vattsVersion}${console_1.Colors.Reset}`);
|
|
19
|
+
console.log(`${timer}${dim}────────────────────────────────────────${console_1.Colors.Reset}`);
|
|
20
|
+
console.log(`${timer}${ok}✔${console_1.Colors.Reset} ${bright}Project ${console_1.Colors.FgWhite}${ctx.appName}${console_1.Colors.Reset}${bright} created successfully.${console_1.Colors.Reset}`);
|
|
21
|
+
console.log("");
|
|
22
|
+
console.log(`${timer}${label}Environment:${console_1.Colors.Reset}`);
|
|
23
|
+
console.log(`${timer}${label} • Runtime:${console_1.Colors.Reset} ${console_1.Colors.Bright + console_1.Colors.FgGreen}Node.js${console_1.Colors.Reset} ${dim}${nodeVersion}${console_1.Colors.Reset}`);
|
|
24
|
+
console.log(`${timer}${label} • Platform:${console_1.Colors.Reset} ${cmd}${platform}${console_1.Colors.Reset}`);
|
|
25
|
+
console.log(`${timer}${label} • Framework:${console_1.Colors.Reset} ${cmd}Vatts.js${console_1.Colors.Reset} ${dim}v${ctx.vattsVersion}${console_1.Colors.Reset}`);
|
|
26
|
+
console.log("");
|
|
27
|
+
console.log(`${timer}${label}Next steps:${console_1.Colors.Reset}`);
|
|
28
|
+
console.log(`${timer}${label} 1.${console_1.Colors.Reset} ${cmd}cd ${ctx.appName}${console_1.Colors.Reset}`);
|
|
29
|
+
let step = 2;
|
|
30
|
+
if (!ctx.willInstallDependencies) {
|
|
31
|
+
console.log(`${timer}${label} ${step++}.${console_1.Colors.Reset} ${cmd}npm install${console_1.Colors.Reset}`);
|
|
32
|
+
}
|
|
33
|
+
console.log(`${timer}${label} ${step++}.${console_1.Colors.Reset} ${cmd}vatts dev${console_1.Colors.Reset}${console_1.Colors.Reset}`);
|
|
34
|
+
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
35
|
+
console.log(`${timer}${label} ${cmd}npm run dev${console_1.Colors.Reset}`);
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log(`${timer}${label}Production:${console_1.Colors.Reset}`);
|
|
38
|
+
console.log(`${timer}${label} • Start:${console_1.Colors.Reset} ${cmd}vatts start${console_1.Colors.Reset}`);
|
|
39
|
+
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
40
|
+
console.log(`${timer}${label} ${cmd}npm run start${console_1.Colors.Reset}`);
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log(`${timer}${dim}Website:${console_1.Colors.Reset} ${console_1.Colors.FgCyan}https://vatts.mfraz.ovh${console_1.Colors.Reset}`);
|
|
43
|
+
console.log("");
|
|
44
|
+
console.log();
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function globalsCssTemplate(willTailwind: boolean): "@import \"tailwindcss\";\n" | "body {\nbackground-color: #030712; \n}";
|
|
2
|
+
export declare function layoutTsxTemplate(): string;
|
|
3
|
+
export declare function layoutJsxTemplate(): string;
|
|
4
|
+
export declare function vattsConfigTemplate(typescript: boolean, pathRouter: boolean): string;
|
|
5
|
+
export declare function tsconfigTemplate(opts?: {
|
|
6
|
+
moduleAlias?: string | false;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function postcssConfigTemplate(): string;
|
|
9
|
+
export declare function tailwindConfigTemplate(): string;
|
|
10
|
+
export declare function webIndexRouteTemplate(willTailwind: boolean, pathRouter: boolean, typescript: boolean): string;
|
|
11
|
+
export declare function backendExampleRouteTemplate(typescript: boolean): "import {VattsResponse} from \"vatts\"\n\nconst ExampleRoute = {\n pattern: '/api/example',\n GET(request, params) {\n return VattsResponse.json({\n message: 'Welcome to the Example API!'\n })\n },\n POST: async (request, params) => {\n const data = await request.json();\n return VattsResponse.json({\n message: 'POST request received at Example API!',\n body: data\n })\n }\n};\n\nexport default ExampleRoute;" | "import {BackendRouteConfig, VattsRequest, VattsResponse} from \"vatts\"\n\nconst ExampleRoute: BackendRouteConfig = {\n pattern: '/api/example',\n GET(request: VattsRequest, params) {\n return VattsResponse.json({\n message: 'Welcome to the Example API!'\n })\n },\n POST: async (request: VattsRequest, params) => {\n const data = await request.json();\n return VattsResponse.json({\n message: 'POST request received at Example API!',\n body: data\n })\n }\n};\n\nexport default ExampleRoute;";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.globalsCssTemplate = globalsCssTemplate;
|
|
4
4
|
exports.layoutTsxTemplate = layoutTsxTemplate;
|
|
5
|
+
exports.layoutJsxTemplate = layoutJsxTemplate;
|
|
5
6
|
exports.vattsConfigTemplate = vattsConfigTemplate;
|
|
6
7
|
exports.tsconfigTemplate = tsconfigTemplate;
|
|
7
8
|
exports.postcssConfigTemplate = postcssConfigTemplate;
|
|
@@ -38,14 +39,49 @@ export default function Layout({ children }: LayoutProps) {
|
|
|
38
39
|
}
|
|
39
40
|
`;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function layoutJsxTemplate() {
|
|
43
|
+
// keeping same content/behavior as original generator
|
|
44
|
+
return `import React from 'react';
|
|
45
|
+
import './globals.css';
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const metadata = {
|
|
49
|
+
title: "Vatts JS | The Fast and Simple Web Framework for React",
|
|
50
|
+
description: "The fastest and simplest web framework for React! Start building high-performance web applications today with Vatts JS.",
|
|
51
|
+
keywords: ["Vatts JS", "web framework", "React", "JavaScript", "TypeScript", "web development", "fast", "simple", "SSR", "frontend"],
|
|
52
|
+
author: "Vatts JS Team",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default function Layout({ children }) {
|
|
56
|
+
return (
|
|
57
|
+
<>{children}</>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
function vattsConfigTemplate(typescript, pathRouter) {
|
|
63
|
+
if (!typescript) {
|
|
64
|
+
return `
|
|
65
|
+
const vattsConfig = (phase, { defaultConfig }) => {
|
|
66
|
+
return {
|
|
67
|
+
...defaultConfig${pathRouter ? `,
|
|
68
|
+
pathRouter: true` : ''}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default vattsConfig;
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
42
75
|
return `import type { VattsConfigFunction } from 'vatts';
|
|
43
76
|
|
|
44
|
-
const
|
|
45
|
-
return
|
|
77
|
+
const vattsConfig: VattsConfigFunction = (phase, { defaultConfig }) => {
|
|
78
|
+
return {
|
|
79
|
+
...defaultConfig${pathRouter ? `,
|
|
80
|
+
pathRouter: true` : ''}
|
|
81
|
+
};
|
|
46
82
|
};
|
|
47
83
|
|
|
48
|
-
export default
|
|
84
|
+
export default vattsConfig;`;
|
|
49
85
|
}
|
|
50
86
|
function tsconfigTemplate(opts) {
|
|
51
87
|
const aliasPrefix = opts?.moduleAlias;
|
|
@@ -68,6 +104,7 @@ function tsconfigTemplate(opts) {
|
|
|
68
104
|
"strict": true,
|
|
69
105
|
"esModuleInterop": true,
|
|
70
106
|
"resolveJsonModule": true,
|
|
107
|
+
"allowJs": true,
|
|
71
108
|
"skipLibCheck": true,
|
|
72
109
|
"forceConsistentCasingInFileNames": true,
|
|
73
110
|
"rootDir": "./src",
|
|
@@ -104,12 +141,13 @@ module.exports = {
|
|
|
104
141
|
plugins: [],
|
|
105
142
|
}`;
|
|
106
143
|
}
|
|
107
|
-
function webIndexRouteTemplate(willTailwind) {
|
|
144
|
+
function webIndexRouteTemplate(willTailwind, pathRouter, typescript) {
|
|
145
|
+
const functionName = pathRouter ? 'export default function' : 'function';
|
|
108
146
|
let base = `import React from 'react';
|
|
109
147
|
import {RouteConfig} from "vatts/react";`;
|
|
110
148
|
if (willTailwind) {
|
|
111
149
|
base += `
|
|
112
|
-
|
|
150
|
+
${functionName} Welcome() {
|
|
113
151
|
return (
|
|
114
152
|
<div className="flex min-h-screen flex-col items-center justify-center bg-gray-950 p-4 text-center">
|
|
115
153
|
<div className="group relative">
|
|
@@ -131,11 +169,11 @@ function Welcome() {
|
|
|
131
169
|
}
|
|
132
170
|
else {
|
|
133
171
|
base += `
|
|
134
|
-
|
|
172
|
+
${functionName} Welcome() {
|
|
135
173
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
136
174
|
|
|
137
175
|
// Definição dos estilos
|
|
138
|
-
const styles: { [key: string]: React.CSSProperties } = {
|
|
176
|
+
const styles${typescript ? ': { [key: string]: React.CSSProperties }' : ''} = {
|
|
139
177
|
container: {
|
|
140
178
|
display: 'flex',
|
|
141
179
|
minHeight: '100vh',
|
|
@@ -218,9 +256,10 @@ function Welcome() {
|
|
|
218
256
|
);
|
|
219
257
|
}`;
|
|
220
258
|
}
|
|
221
|
-
|
|
259
|
+
if (!pathRouter) {
|
|
260
|
+
base += `
|
|
222
261
|
|
|
223
|
-
export const config: RouteConfig = {
|
|
262
|
+
export const config${typescript ? ': RouteConfig' : ''} = {
|
|
224
263
|
pattern: '/',
|
|
225
264
|
component: Welcome,
|
|
226
265
|
generateMetadata: () => ({
|
|
@@ -230,9 +269,31 @@ export const config: RouteConfig = {
|
|
|
230
269
|
|
|
231
270
|
export default config;
|
|
232
271
|
`;
|
|
272
|
+
}
|
|
233
273
|
return base;
|
|
234
274
|
}
|
|
235
|
-
function backendExampleRouteTemplate() {
|
|
275
|
+
function backendExampleRouteTemplate(typescript) {
|
|
276
|
+
if (!typescript) {
|
|
277
|
+
return `import {VattsResponse} from "vatts"
|
|
278
|
+
|
|
279
|
+
const ExampleRoute = {
|
|
280
|
+
pattern: '/api/example',
|
|
281
|
+
GET(request, params) {
|
|
282
|
+
return VattsResponse.json({
|
|
283
|
+
message: 'Welcome to the Example API!'
|
|
284
|
+
})
|
|
285
|
+
},
|
|
286
|
+
POST: async (request, params) => {
|
|
287
|
+
const data = await request.json();
|
|
288
|
+
return VattsResponse.json({
|
|
289
|
+
message: 'POST request received at Example API!',
|
|
290
|
+
body: data
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export default ExampleRoute;`;
|
|
296
|
+
}
|
|
236
297
|
return `import {BackendRouteConfig, VattsRequest, VattsResponse} from "vatts"
|
|
237
298
|
|
|
238
299
|
const ExampleRoute: BackendRouteConfig = {
|
|
@@ -8,6 +8,8 @@ export type CreateAppOptions = {
|
|
|
8
8
|
moduleAlias?: boolean;
|
|
9
9
|
/** Alias prefix to use when moduleAlias=true (default: "@/") */
|
|
10
10
|
alias?: string;
|
|
11
|
+
pathRouter?: boolean;
|
|
12
|
+
typeScript?: boolean;
|
|
11
13
|
};
|
|
12
14
|
export type CreateAppContext = {
|
|
13
15
|
appName: string;
|
|
@@ -16,9 +18,11 @@ export type CreateAppContext = {
|
|
|
16
18
|
willRouteExample: boolean;
|
|
17
19
|
willInstallDependencies: boolean;
|
|
18
20
|
willUseModuleAlias: boolean;
|
|
21
|
+
pathRouter: boolean;
|
|
19
22
|
/** Normalized alias prefix (ex: "@/") */
|
|
20
23
|
moduleAlias: string;
|
|
21
24
|
/** computed */
|
|
22
25
|
vattsVersion: string;
|
|
23
26
|
packageJson: Record<string, any>;
|
|
27
|
+
typeScript: boolean;
|
|
24
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vatts-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CLI tool to create a new Vatts.js application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"commander": "^14.0.2",
|
|
29
29
|
"ts-node": "^10.9.2",
|
|
30
|
-
"vatts": "1.0
|
|
30
|
+
"vatts": "1.1.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "rimraf dist && tsc",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./createApp";
|
package/dist/createApp/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./createApp"), exports);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CreateAppContext } from "./types";
|
|
2
|
-
export declare function stepCreateProjectDirAndPackageJson(ctx: CreateAppContext): Promise<void>;
|
|
3
|
-
export declare function stepCreateProjectStructure(ctx: CreateAppContext): Promise<void>;
|
|
4
|
-
export declare function stepWriteVattsConfig(ctx: CreateAppContext): Promise<void>;
|
|
5
|
-
export declare function stepWriteTsConfig(ctx: CreateAppContext): Promise<void>;
|
|
6
|
-
export declare function stepSetupTailwind(ctx: CreateAppContext): Promise<void>;
|
|
7
|
-
export declare function stepCreateExampleRoutes(ctx: CreateAppContext): Promise<void>;
|
|
8
|
-
export declare function stepInstallDependencies(ctx: CreateAppContext): Promise<void>;
|
|
9
|
-
export declare function printSummary(ctx: CreateAppContext): void;
|
package/dist/createApp/steps.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.stepCreateProjectDirAndPackageJson = stepCreateProjectDirAndPackageJson;
|
|
37
|
-
exports.stepCreateProjectStructure = stepCreateProjectStructure;
|
|
38
|
-
exports.stepWriteVattsConfig = stepWriteVattsConfig;
|
|
39
|
-
exports.stepWriteTsConfig = stepWriteTsConfig;
|
|
40
|
-
exports.stepSetupTailwind = stepSetupTailwind;
|
|
41
|
-
exports.stepCreateExampleRoutes = stepCreateExampleRoutes;
|
|
42
|
-
exports.stepInstallDependencies = stepInstallDependencies;
|
|
43
|
-
exports.printSummary = printSummary;
|
|
44
|
-
const console_1 = __importStar(require("vatts/console"));
|
|
45
|
-
const path = __importStar(require("node:path"));
|
|
46
|
-
const fs_1 = require("./fs");
|
|
47
|
-
const templates_1 = require("./templates");
|
|
48
|
-
const packageJson_1 = require("./packageJson");
|
|
49
|
-
const install_1 = require("./install");
|
|
50
|
-
async function stepCreateProjectDirAndPackageJson(ctx) {
|
|
51
|
-
const dynamic = console_1.default.dynamicLine("Creating your Vatts.js app...");
|
|
52
|
-
(0, fs_1.ensureDir)(ctx.rootDir);
|
|
53
|
-
ctx.packageJson = await (0, packageJson_1.buildPackageJson)({
|
|
54
|
-
appName: ctx.appName,
|
|
55
|
-
vattsVersion: ctx.vattsVersion,
|
|
56
|
-
willTailwind: ctx.willTailwind,
|
|
57
|
-
});
|
|
58
|
-
(0, fs_1.writeJson)(path.join(ctx.rootDir, "package.json"), ctx.packageJson);
|
|
59
|
-
dynamic.end("Created project directory and package.json");
|
|
60
|
-
}
|
|
61
|
-
async function stepCreateProjectStructure(ctx) {
|
|
62
|
-
const dynamic = console_1.default.dynamicLine("Creating project structure...");
|
|
63
|
-
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "backend", "routes"));
|
|
64
|
-
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web", "routes"));
|
|
65
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", "globals.css"), (0, templates_1.globalsCssTemplate)(ctx.willTailwind));
|
|
66
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", "layout.tsx"), (0, templates_1.layoutTsxTemplate)());
|
|
67
|
-
dynamic.end("Created project structure");
|
|
68
|
-
}
|
|
69
|
-
async function stepWriteVattsConfig(ctx) {
|
|
70
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "vatts.config.ts"), (0, templates_1.vattsConfigTemplate)());
|
|
71
|
-
}
|
|
72
|
-
async function stepWriteTsConfig(ctx) {
|
|
73
|
-
const dynamic = console_1.default.dynamicLine("Initializing TypeScript configuration...");
|
|
74
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "tsconfig.json"), (0, templates_1.tsconfigTemplate)(ctx.willUseModuleAlias ? { moduleAlias: ctx.moduleAlias } : { moduleAlias: false }));
|
|
75
|
-
dynamic.end("TypeScript configuration initialized.");
|
|
76
|
-
}
|
|
77
|
-
async function stepSetupTailwind(ctx) {
|
|
78
|
-
if (!ctx.willTailwind)
|
|
79
|
-
return;
|
|
80
|
-
const dynamic = console_1.default.dynamicLine("Setting up Tailwind CSS...");
|
|
81
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "postcss.config.js"), (0, templates_1.postcssConfigTemplate)());
|
|
82
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "tailwind.config.js"), (0, templates_1.tailwindConfigTemplate)());
|
|
83
|
-
dynamic.end("Tailwind CSS setup complete.");
|
|
84
|
-
}
|
|
85
|
-
async function stepCreateExampleRoutes(ctx) {
|
|
86
|
-
if (!ctx.willRouteExample)
|
|
87
|
-
return;
|
|
88
|
-
const dynamic = console_1.default.dynamicLine("Creating example routes...");
|
|
89
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", "routes", "index.tsx"), (0, templates_1.webIndexRouteTemplate)(ctx.willTailwind));
|
|
90
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "backend", "routes", "Example.ts"), (0, templates_1.backendExampleRouteTemplate)());
|
|
91
|
-
dynamic.end("Example routes created.");
|
|
92
|
-
}
|
|
93
|
-
async function stepInstallDependencies(ctx) {
|
|
94
|
-
if (!ctx.willInstallDependencies)
|
|
95
|
-
return;
|
|
96
|
-
const dynamic = console_1.default.dynamicLine("Installing dependencies...");
|
|
97
|
-
console.log(`\nInstalling dependencies:\n${ctx.packageJson.dependencies
|
|
98
|
-
? Object.keys(ctx.packageJson.dependencies)
|
|
99
|
-
.map((dep) => ` - ${console_1.Colors.FgCyan}${dep}${console_1.Colors.Reset}`)
|
|
100
|
-
.join("\n")
|
|
101
|
-
: ""}\n\nInstalling devDependencies:\n${ctx.packageJson.devDependencies
|
|
102
|
-
? Object.keys(ctx.packageJson.devDependencies)
|
|
103
|
-
.map((dep) => ` - ${console_1.Colors.FgCyan}${dep}${console_1.Colors.Reset}`)
|
|
104
|
-
.join("\n")
|
|
105
|
-
: ""}\n`);
|
|
106
|
-
const spinnerFrames = ["|", "/", "-", "\\"];
|
|
107
|
-
let frameIndex = 0;
|
|
108
|
-
const spinner = setInterval(() => {
|
|
109
|
-
dynamic.update(`${console_1.Colors.FgGreen}${spinnerFrames[frameIndex]}${console_1.Colors.Reset} Installing...`);
|
|
110
|
-
frameIndex = (frameIndex + 1) % spinnerFrames.length;
|
|
111
|
-
}, 100);
|
|
112
|
-
try {
|
|
113
|
-
await (0, install_1.npmInstall)(ctx.rootDir);
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
clearInterval(spinner);
|
|
117
|
-
}
|
|
118
|
-
dynamic.end("Dependencies installed.");
|
|
119
|
-
}
|
|
120
|
-
function printSummary(ctx) {
|
|
121
|
-
console.clear();
|
|
122
|
-
const now = new Date();
|
|
123
|
-
const time = now.toLocaleTimeString("pt-BR", { hour12: false });
|
|
124
|
-
const timer = ` ${console_1.Colors.FgGray}${time}${console_1.Colors.Reset} `;
|
|
125
|
-
const label = console_1.Colors.FgGray;
|
|
126
|
-
const cmd = console_1.Colors.Bright + console_1.Colors.FgCyan;
|
|
127
|
-
const ok = console_1.Colors.FgGreen;
|
|
128
|
-
const dim = console_1.Colors.Dim;
|
|
129
|
-
const bright = console_1.Colors.Bright;
|
|
130
|
-
const nodeVersion = process.version;
|
|
131
|
-
const platform = process.platform;
|
|
132
|
-
console.log("");
|
|
133
|
-
console.log(`${timer}${bright}${console_1.Colors.FgCyan}Vatts.js${console_1.Colors.Reset} ${dim}v${ctx.vattsVersion}${console_1.Colors.Reset}`);
|
|
134
|
-
console.log(`${timer}${dim}────────────────────────────────────────${console_1.Colors.Reset}`);
|
|
135
|
-
console.log(`${timer}${ok}✔${console_1.Colors.Reset} ${bright}Project ${console_1.Colors.FgWhite}${ctx.appName}${console_1.Colors.Reset}${bright} created successfully.${console_1.Colors.Reset}`);
|
|
136
|
-
console.log("");
|
|
137
|
-
console.log(`${timer}${label}Environment:${console_1.Colors.Reset}`);
|
|
138
|
-
console.log(`${timer}${label} • Runtime:${console_1.Colors.Reset} ${console_1.Colors.Bright + console_1.Colors.FgGreen}Node.js${console_1.Colors.Reset} ${dim}${nodeVersion}${console_1.Colors.Reset}`);
|
|
139
|
-
console.log(`${timer}${label} • Platform:${console_1.Colors.Reset} ${cmd}${platform}${console_1.Colors.Reset}`);
|
|
140
|
-
console.log(`${timer}${label} • Framework:${console_1.Colors.Reset} ${cmd}Vatts.js${console_1.Colors.Reset} ${dim}v${ctx.vattsVersion}${console_1.Colors.Reset}`);
|
|
141
|
-
console.log("");
|
|
142
|
-
console.log(`${timer}${label}Next steps:${console_1.Colors.Reset}`);
|
|
143
|
-
console.log(`${timer}${label} 1.${console_1.Colors.Reset} ${cmd}cd ${ctx.appName}${console_1.Colors.Reset}`);
|
|
144
|
-
let step = 2;
|
|
145
|
-
if (!ctx.willInstallDependencies) {
|
|
146
|
-
console.log(`${timer}${label} ${step++}.${console_1.Colors.Reset} ${cmd}npm install${console_1.Colors.Reset}`);
|
|
147
|
-
}
|
|
148
|
-
console.log(`${timer}${label} ${step++}.${console_1.Colors.Reset} ${cmd}vatts dev${console_1.Colors.Reset}${console_1.Colors.Reset}`);
|
|
149
|
-
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
150
|
-
console.log(`${timer}${label} ${cmd}npm run dev${console_1.Colors.Reset}`);
|
|
151
|
-
console.log("");
|
|
152
|
-
console.log(`${timer}${label}Production:${console_1.Colors.Reset}`);
|
|
153
|
-
console.log(`${timer}${label} • Start:${console_1.Colors.Reset} ${cmd}vatts start${console_1.Colors.Reset}`);
|
|
154
|
-
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
155
|
-
console.log(`${timer}${label} ${cmd}npm run start${console_1.Colors.Reset}`);
|
|
156
|
-
console.log("");
|
|
157
|
-
console.log(`${timer}${dim}Website:${console_1.Colors.Reset} ${console_1.Colors.FgCyan}https://vatts.mfraz.ovh${console_1.Colors.Reset}`);
|
|
158
|
-
console.log("");
|
|
159
|
-
console.log();
|
|
160
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function globalsCssTemplate(willTailwind: boolean): "@import \"tailwindcss\";\n" | "body {\nbackground-color: #030712; \n}";
|
|
2
|
-
export declare function layoutTsxTemplate(): string;
|
|
3
|
-
export declare function vattsConfigTemplate(): string;
|
|
4
|
-
export declare function tsconfigTemplate(opts?: {
|
|
5
|
-
moduleAlias?: string | false;
|
|
6
|
-
}): string;
|
|
7
|
-
export declare function postcssConfigTemplate(): string;
|
|
8
|
-
export declare function tailwindConfigTemplate(): string;
|
|
9
|
-
export declare function webIndexRouteTemplate(willTailwind: boolean): string;
|
|
10
|
-
export declare function backendExampleRouteTemplate(): string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|