create-vatts-app 1.1.1 → 1.2.0-canary
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.js +0 -12
- package/dist/createApp.js +0 -1
- package/dist/steps/createExampleRoutes.js +4 -10
- package/dist/steps/createProjectStructure.js +1 -6
- package/dist/steps/writeVattsConfig.js +1 -1
- package/dist/summary.js +5 -4
- package/dist/templates.d.ts +3 -3
- package/dist/templates.js +7 -33
- package/dist/types.d.ts +0 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -83,8 +83,6 @@ function parseArgs(argv) {
|
|
|
83
83
|
const examplesFlag = args.includes("--examples");
|
|
84
84
|
const noAliasFlag = args.includes("--no-alias");
|
|
85
85
|
const aliasValue = readArgValue(args, "--alias");
|
|
86
|
-
const pathRouterFlag = args.includes("--path-router") || args.includes("-p");
|
|
87
|
-
const noPathRouterFlag = args.includes("--no-path-router");
|
|
88
86
|
const reactFlag = args.includes("--react");
|
|
89
87
|
const vueFlag = args.includes("--vue");
|
|
90
88
|
return {
|
|
@@ -95,7 +93,6 @@ function parseArgs(argv) {
|
|
|
95
93
|
install: noInstallFlag ? false : installFlag ? true : undefined,
|
|
96
94
|
moduleAlias: noAliasFlag ? false : aliasValue ? true : undefined,
|
|
97
95
|
alias: aliasValue ? normalizeAliasPrefix(aliasValue) : undefined,
|
|
98
|
-
pathRouter: pathRouterFlag ? true : noPathRouterFlag ? false : undefined,
|
|
99
96
|
typeScript: args.includes("--typescript") || args.includes("-ts") ? true : undefined,
|
|
100
97
|
framework: reactFlag ? 'react' : vueFlag ? 'vue' : undefined
|
|
101
98
|
};
|
|
@@ -137,11 +134,9 @@ async function promptForMissingOptions(opts) {
|
|
|
137
134
|
let name = framework === 'react' ? 'React' : 'Vue';
|
|
138
135
|
const recommended = await console_1.default.selection(`Would you like to use the recommended options? (${name})`, {
|
|
139
136
|
"yes": `${console_1.Colors.Underscore}Yes, use recommended defaults - TypeScript, Tailwind CSS, Module Alias`,
|
|
140
|
-
"maybe": `Maybe, use Path Router defaults - TypeScript, Tailwind CSS`,
|
|
141
137
|
"no": "No, customize settings"
|
|
142
138
|
});
|
|
143
139
|
if (recommended !== 'no') {
|
|
144
|
-
recommendedOptions.pathRouter = recommended === 'maybe';
|
|
145
140
|
// Forçar todas as propriedades obrigatórias
|
|
146
141
|
return {
|
|
147
142
|
appName: recommendedOptions.appName,
|
|
@@ -150,7 +145,6 @@ async function promptForMissingOptions(opts) {
|
|
|
150
145
|
install: recommendedOptions.install,
|
|
151
146
|
moduleAlias: recommendedOptions.moduleAlias,
|
|
152
147
|
alias: recommendedOptions.alias,
|
|
153
|
-
pathRouter: recommendedOptions.pathRouter,
|
|
154
148
|
typeScript: recommendedOptions.typeScript,
|
|
155
149
|
framework: recommendedOptions.framework
|
|
156
150
|
};
|
|
@@ -170,11 +164,6 @@ async function promptForMissingOptions(opts) {
|
|
|
170
164
|
examples = await console_1.default.confirm("Do you want to include example routes?", true);
|
|
171
165
|
console.log(" ");
|
|
172
166
|
}
|
|
173
|
-
let pathRouter = opts.pathRouter;
|
|
174
|
-
if (pathRouter === undefined) {
|
|
175
|
-
pathRouter = await console_1.default.confirm("Do you want to use path router?", false);
|
|
176
|
-
console.log(" ");
|
|
177
|
-
}
|
|
178
167
|
let moduleAlias = opts.moduleAlias;
|
|
179
168
|
if (moduleAlias === undefined) {
|
|
180
169
|
moduleAlias = await console_1.default.confirm("Do you want to set a module alias?", true);
|
|
@@ -204,7 +193,6 @@ async function promptForMissingOptions(opts) {
|
|
|
204
193
|
install: install,
|
|
205
194
|
moduleAlias: moduleAlias,
|
|
206
195
|
alias: alias,
|
|
207
|
-
pathRouter: pathRouter,
|
|
208
196
|
typeScript: typescript,
|
|
209
197
|
framework: framework
|
|
210
198
|
};
|
package/dist/createApp.js
CHANGED
|
@@ -60,18 +60,12 @@ const templates_1 = require("../templates");
|
|
|
60
60
|
async function createExampleRoutes(ctx) {
|
|
61
61
|
const dynamic = console_1.default.dynamicLine("Creating example routes...");
|
|
62
62
|
if (ctx.framework === 'react') {
|
|
63
|
-
let pathResolve = path.join(ctx.rootDir, "src", "web",
|
|
64
|
-
|
|
65
|
-
pathResolve = path.join(ctx.rootDir, "src", "web", `page.${ctx.typeScript ? 'tsx' : 'jsx'}`);
|
|
66
|
-
}
|
|
67
|
-
(0, fs_1.writeFile)(pathResolve, (0, templates_1.webIndexRouteTemplate)(ctx.willTailwind, ctx.pathRouter, ctx.typeScript));
|
|
63
|
+
let pathResolve = path.join(ctx.rootDir, "src", "web", `page.${ctx.typeScript ? 'tsx' : 'jsx'}`);
|
|
64
|
+
(0, fs_1.writeFile)(pathResolve, (0, templates_1.webIndexRouteTemplate)(ctx.willTailwind, ctx.typeScript));
|
|
68
65
|
}
|
|
69
66
|
else if (ctx.framework === 'vue') {
|
|
70
|
-
let pathResolve = path.join(ctx.rootDir, "src", "web",
|
|
71
|
-
|
|
72
|
-
pathResolve = path.join(ctx.rootDir, "src", "web", `page.vue`);
|
|
73
|
-
}
|
|
74
|
-
(0, fs_1.writeFile)(pathResolve, (0, templates_1.vueExampleRoute)(ctx.typeScript, ctx.pathRouter, ctx.willTailwind));
|
|
67
|
+
let pathResolve = path.join(ctx.rootDir, "src", "web", `page.vue`);
|
|
68
|
+
(0, fs_1.writeFile)(pathResolve, (0, templates_1.vueExampleRoute)(ctx.typeScript, ctx.willTailwind));
|
|
75
69
|
}
|
|
76
70
|
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "backend", "routes", `Example.${ctx.typeScript ? 'ts' : 'js'}`), (0, templates_1.backendExampleRouteTemplate)(ctx.typeScript));
|
|
77
71
|
dynamic.end("Example routes created.");
|
|
@@ -60,12 +60,7 @@ const templates_1 = require("../templates");
|
|
|
60
60
|
async function createProjectStructure(ctx) {
|
|
61
61
|
const dynamic = console_1.default.dynamicLine("Creating project structure...");
|
|
62
62
|
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "backend", "routes"));
|
|
63
|
-
|
|
64
|
-
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web", "routes"));
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web"));
|
|
68
|
-
}
|
|
63
|
+
(0, fs_1.ensureDir)(path.join(ctx.rootDir, "src", "web"));
|
|
69
64
|
(0, fs_1.writeFile)(path.join(ctx.rootDir, "src", "web", "globals.css"), (0, templates_1.globalsCssTemplate)(ctx.willTailwind));
|
|
70
65
|
if (ctx.framework === 'react') {
|
|
71
66
|
(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)());
|
|
@@ -54,5 +54,5 @@ const path = __importStar(require("node:path"));
|
|
|
54
54
|
const fs_1 = require("../fs");
|
|
55
55
|
const templates_1 = require("../templates");
|
|
56
56
|
async function writeVattsConfig(ctx) {
|
|
57
|
-
(0, fs_1.writeFile)(path.join(ctx.rootDir, `vatts.config.${ctx.typeScript ? 'ts' : 'js'}`), (0, templates_1.vattsConfigTemplate)(ctx.typeScript
|
|
57
|
+
(0, fs_1.writeFile)(path.join(ctx.rootDir, `vatts.config.${ctx.typeScript ? 'ts' : 'js'}`), (0, templates_1.vattsConfigTemplate)(ctx.typeScript));
|
|
58
58
|
}
|
package/dist/summary.js
CHANGED
|
@@ -50,10 +50,11 @@ function printSummary(ctx) {
|
|
|
50
50
|
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
51
51
|
console.log(`${timer}${label} ${cmd}npm run dev${console_1.Colors.Reset}`);
|
|
52
52
|
console.log("");
|
|
53
|
-
console.log(`${timer}${label}Production:${console_1.Colors.Reset}`);
|
|
54
|
-
console.log(`${timer}${label}
|
|
55
|
-
console.log(`${timer}${label}
|
|
56
|
-
console.log(`${timer}${label}
|
|
53
|
+
console.log(`${timer}${label}Production steps:${console_1.Colors.Reset}`);
|
|
54
|
+
console.log(`${timer}${label} 1. ${cmd}vatts build${console_1.Colors.Reset}`);
|
|
55
|
+
console.log(`${timer}${label} 2. ${cmd}vatts start${console_1.Colors.Reset}`);
|
|
56
|
+
console.log(`${timer}${label} or${console_1.Colors.Reset}`);
|
|
57
|
+
console.log(`${timer}${label} ${cmd}npm run start${console_1.Colors.Reset}`);
|
|
57
58
|
console.log("");
|
|
58
59
|
console.log(`${timer}${dim}Website:${console_1.Colors.Reset} ${console_1.Colors.FgCyan}https://vatts.mfraz.ovh${console_1.Colors.Reset}`);
|
|
59
60
|
console.log("");
|
package/dist/templates.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare function globalsCssTemplate(willTailwind: boolean): "@import \"tailwindcss\";\n" | "body {\nbackground-color: #030712; \n}";
|
|
2
2
|
export declare function layoutTsxTemplate(): string;
|
|
3
3
|
export declare function layoutJsxTemplate(): string;
|
|
4
|
-
export declare function vattsConfigTemplate(typescript: boolean,
|
|
4
|
+
export declare function vattsConfigTemplate(typescript: boolean): "\nconst vattsConfig = (phase, { defaultConfig }) => {\n return {\n ...defaultConfig\n };\n};\n\nexport default vattsConfig;\n " | "import type { VattsConfigFunction } from 'vatts';\n\nconst vattsConfig: VattsConfigFunction = (phase, { defaultConfig }) => {\n return {\n ...defaultConfig\n };\n};\n\nexport default vattsConfig;";
|
|
5
5
|
export declare function tsconfigTemplate(opts?: {
|
|
6
6
|
moduleAlias?: string | false;
|
|
7
7
|
}): string;
|
|
8
8
|
export declare function postcssConfigTemplate(): string;
|
|
9
9
|
export declare function tailwindConfigTemplate(): string;
|
|
10
|
-
export declare function webIndexRouteTemplate(willTailwind: boolean,
|
|
10
|
+
export declare function webIndexRouteTemplate(willTailwind: boolean, typescript: boolean): string;
|
|
11
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;";
|
|
12
|
-
export declare function vueExampleRoute(typescript: boolean,
|
|
12
|
+
export declare function vueExampleRoute(typescript: boolean, tailwind: boolean): string;
|
|
13
13
|
export declare function vueExampleLayout(typescript: boolean): string;
|
package/dist/templates.js
CHANGED
|
@@ -77,13 +77,12 @@ export default function Layout({ children }) {
|
|
|
77
77
|
}
|
|
78
78
|
`;
|
|
79
79
|
}
|
|
80
|
-
function vattsConfigTemplate(typescript
|
|
80
|
+
function vattsConfigTemplate(typescript) {
|
|
81
81
|
if (!typescript) {
|
|
82
82
|
return `
|
|
83
83
|
const vattsConfig = (phase, { defaultConfig }) => {
|
|
84
84
|
return {
|
|
85
|
-
...defaultConfig
|
|
86
|
-
pathRouter: true` : ''}
|
|
85
|
+
...defaultConfig
|
|
87
86
|
};
|
|
88
87
|
};
|
|
89
88
|
|
|
@@ -94,8 +93,7 @@ export default vattsConfig;
|
|
|
94
93
|
|
|
95
94
|
const vattsConfig: VattsConfigFunction = (phase, { defaultConfig }) => {
|
|
96
95
|
return {
|
|
97
|
-
...defaultConfig
|
|
98
|
-
pathRouter: true` : ''}
|
|
96
|
+
...defaultConfig
|
|
99
97
|
};
|
|
100
98
|
};
|
|
101
99
|
|
|
@@ -159,8 +157,8 @@ module.exports = {
|
|
|
159
157
|
plugins: [],
|
|
160
158
|
}`;
|
|
161
159
|
}
|
|
162
|
-
function webIndexRouteTemplate(willTailwind,
|
|
163
|
-
const functionName =
|
|
160
|
+
function webIndexRouteTemplate(willTailwind, typescript) {
|
|
161
|
+
const functionName = 'export default function';
|
|
164
162
|
let base = `import React from 'react';
|
|
165
163
|
import {RouteConfig} from "vatts/react";`;
|
|
166
164
|
if (willTailwind) {
|
|
@@ -273,20 +271,6 @@ ${functionName} Welcome() {
|
|
|
273
271
|
</div>
|
|
274
272
|
);
|
|
275
273
|
}`;
|
|
276
|
-
}
|
|
277
|
-
if (!pathRouter) {
|
|
278
|
-
base += `
|
|
279
|
-
|
|
280
|
-
export const config${typescript ? ': RouteConfig' : ''} = {
|
|
281
|
-
pattern: '/',
|
|
282
|
-
component: Welcome,
|
|
283
|
-
generateMetadata: () => ({
|
|
284
|
-
title: 'Vatts.js | Home'
|
|
285
|
-
})
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
export default config;
|
|
289
|
-
`;
|
|
290
274
|
}
|
|
291
275
|
return base;
|
|
292
276
|
}
|
|
@@ -332,18 +316,8 @@ const ExampleRoute: BackendRouteConfig = {
|
|
|
332
316
|
|
|
333
317
|
export default ExampleRoute;`;
|
|
334
318
|
}
|
|
335
|
-
function vueExampleRoute(typescript,
|
|
336
|
-
return `${
|
|
337
|
-
${typescript ? 'import type { RouteConfig } from "vatts/vue";\n' : ''}
|
|
338
|
-
export const config${typescript ? ': RouteConfig' : ''} = {
|
|
339
|
-
pattern: '/',
|
|
340
|
-
component: undefined,
|
|
341
|
-
generateMetadata: () => ({
|
|
342
|
-
title: 'Vatts.js | Home'
|
|
343
|
-
})
|
|
344
|
-
};
|
|
345
|
-
</script>`}
|
|
346
|
-
${tailwind ? `<template>
|
|
319
|
+
function vueExampleRoute(typescript, tailwind) {
|
|
320
|
+
return `${tailwind ? `<template>
|
|
347
321
|
<div class="flex min-h-screen flex-col items-center justify-center bg-gray-950 p-4 text-center">
|
|
348
322
|
<div class="group relative">
|
|
349
323
|
<div class="absolute -inset-1 rounded-lg bg-gradient-to-r from-purple-600 to-cyan-400 opacity-25 blur transition duration-500 group-hover:opacity-50"></div>
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ 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
11
|
typeScript?: boolean;
|
|
13
12
|
framework?: 'react' | 'vue';
|
|
14
13
|
};
|
|
@@ -19,7 +18,6 @@ export type CreateAppContext = {
|
|
|
19
18
|
willRouteExample: boolean;
|
|
20
19
|
willInstallDependencies: boolean;
|
|
21
20
|
willUseModuleAlias: boolean;
|
|
22
|
-
pathRouter: boolean;
|
|
23
21
|
/** Normalized alias prefix (ex: "@/") */
|
|
24
22
|
moduleAlias: string;
|
|
25
23
|
/** computed */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vatts-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-canary",
|
|
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.2
|
|
30
|
+
"vatts": "2.1.0-canary.2"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "rimraf dist && tsc",
|