revine 1.0.1 → 1.0.4
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/commands/createProject.d.ts.map +1 -1
- package/dist/commands/createProject.js +44 -3
- package/dist/index.js +0 -0
- package/dist/runtime/bundler/defaults/vite.d.ts +0 -6
- package/dist/runtime/bundler/defaults/vite.d.ts.map +1 -1
- package/dist/runtime/bundler/defaults/vite.js +0 -6
- package/dist/runtime/bundler/viteLoggerPlugin.d.ts.map +1 -1
- package/dist/runtime/bundler/viteLoggerPlugin.js +32 -6
- package/package.json +1 -1
- package/src/commands/createProject.ts +55 -9
- package/src/runtime/bundler/defaults/vite.ts +0 -6
- package/src/runtime/bundler/viteLoggerPlugin.ts +35 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/commands/createProject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/commands/createProject.ts"],"names":[],"mappings":"AAsDA,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBA6E7B"}
|
|
@@ -10,6 +10,45 @@ import { copyTemplate } from "../utils/file.js";
|
|
|
10
10
|
import { logError, logInfo } from "../utils/logger.js";
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
|
+
const GITIGNORE_CONTENT = `# Dependencies
|
|
14
|
+
node_modules/
|
|
15
|
+
dist/
|
|
16
|
+
dist-ssr/
|
|
17
|
+
|
|
18
|
+
# Vite cache
|
|
19
|
+
.vite/
|
|
20
|
+
*.local
|
|
21
|
+
|
|
22
|
+
# Environment files
|
|
23
|
+
.env
|
|
24
|
+
.env.local
|
|
25
|
+
.env.development.local
|
|
26
|
+
.env.test.local
|
|
27
|
+
.env.production.local
|
|
28
|
+
|
|
29
|
+
# Logs
|
|
30
|
+
npm-debug.log*
|
|
31
|
+
yarn-debug.log*
|
|
32
|
+
yarn-error.log*
|
|
33
|
+
|
|
34
|
+
# Editor/IDE
|
|
35
|
+
.vscode/
|
|
36
|
+
.idea/
|
|
37
|
+
*.swp
|
|
38
|
+
*.swo
|
|
39
|
+
|
|
40
|
+
# OS metadata
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
|
43
|
+
|
|
44
|
+
# TypeScript build info
|
|
45
|
+
*.tsbuildinfo
|
|
46
|
+
|
|
47
|
+
# Optional
|
|
48
|
+
.cache/
|
|
49
|
+
.tmp/
|
|
50
|
+
.sass-cache/
|
|
51
|
+
`;
|
|
13
52
|
export async function createProject(projectName, options) {
|
|
14
53
|
// Calculate directories. This uses "../../template" for your template folder.
|
|
15
54
|
const templateDir = path.join(__dirname, "../../template");
|
|
@@ -21,6 +60,8 @@ export async function createProject(projectName, options) {
|
|
|
21
60
|
await fs.ensureDir(projectDir);
|
|
22
61
|
// This copies everything, including hidden directories like .revine
|
|
23
62
|
await copyTemplate(templateDir, projectDir, options.force);
|
|
63
|
+
// Explicitly write .gitignore because npm strips it from published tarballs
|
|
64
|
+
await fs.writeFile(path.join(projectDir, ".gitignore"), GITIGNORE_CONTENT);
|
|
24
65
|
// Derive final project name
|
|
25
66
|
const finalProjectName = isCurrentDir
|
|
26
67
|
? path.basename(projectDir)
|
|
@@ -28,12 +69,12 @@ export async function createProject(projectName, options) {
|
|
|
28
69
|
// Check if package.json exists after template copy
|
|
29
70
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
30
71
|
// Create basic package.json if it doesn't exist
|
|
31
|
-
if (!await fs.pathExists(packageJsonPath)) {
|
|
72
|
+
if (!(await fs.pathExists(packageJsonPath))) {
|
|
32
73
|
const basicPackageJson = {
|
|
33
74
|
name: finalProjectName,
|
|
34
75
|
version: "0.1.0",
|
|
35
76
|
private: true,
|
|
36
|
-
type: "module"
|
|
77
|
+
type: "module",
|
|
37
78
|
};
|
|
38
79
|
await fs.writeJSON(packageJsonPath, basicPackageJson, { spaces: 2 });
|
|
39
80
|
}
|
|
@@ -42,7 +83,7 @@ export async function createProject(projectName, options) {
|
|
|
42
83
|
await updatePackageJson(packageJsonPath, finalProjectName, { useTailwind });
|
|
43
84
|
// Check if README exists, create it if it doesn't
|
|
44
85
|
const readmePath = path.join(projectDir, "README.md");
|
|
45
|
-
if (!await fs.pathExists(readmePath)) {
|
|
86
|
+
if (!(await fs.pathExists(readmePath))) {
|
|
46
87
|
await fs.writeFile(readmePath, `# ${finalProjectName}\n\nCreated with Revine`);
|
|
47
88
|
}
|
|
48
89
|
// Update README with the project name
|
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAa7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viteLoggerPlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/viteLoggerPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viteLoggerPlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/viteLoggerPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAwBlD,wBAAgB,kBAAkB,IAAI,MAAM,CAoC3C"}
|
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import os from "os";
|
|
3
|
+
/**
|
|
4
|
+
* Reads all non-internal IPv4 addresses from the host machine's
|
|
5
|
+
* network interfaces so we can display them regardless of Vite's
|
|
6
|
+
* resolvedUrls behaviour (which can be empty when logLevel is silent).
|
|
7
|
+
*/
|
|
8
|
+
function getNetworkAddresses() {
|
|
9
|
+
const interfaces = os.networkInterfaces();
|
|
10
|
+
const addresses = [];
|
|
11
|
+
for (const nets of Object.values(interfaces)) {
|
|
12
|
+
if (!nets)
|
|
13
|
+
continue;
|
|
14
|
+
for (const net of nets) {
|
|
15
|
+
// Only include external IPv4 addresses
|
|
16
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
17
|
+
addresses.push(net.address);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return addresses;
|
|
22
|
+
}
|
|
2
23
|
export function revineLoggerPlugin() {
|
|
3
|
-
// custom chalk instance pointing to the indigo color
|
|
4
24
|
const indigo = chalk.hex("#6d28d9");
|
|
5
25
|
return {
|
|
6
26
|
name: "revine-logger",
|
|
7
27
|
configureServer(server) {
|
|
8
28
|
server.httpServer?.once("listening", () => {
|
|
9
29
|
const protocol = server.config.server.https ? "https" : "http";
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
//
|
|
30
|
+
const port = server.config.server.port ?? 3000;
|
|
31
|
+
const localUrl = server.resolvedUrls?.local[0] ?? `${protocol}://localhost:${port}/`;
|
|
32
|
+
// Always derive network URLs from OS interfaces — reliable even with logLevel: silent
|
|
33
|
+
const networkUrls = server.resolvedUrls?.network?.length
|
|
34
|
+
? server.resolvedUrls.network
|
|
35
|
+
: getNetworkAddresses().map((addr) => `${protocol}://${addr}:${port}/`);
|
|
13
36
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
14
37
|
console.log(indigo.bold("🚀 Revine Dev Server is now running!"));
|
|
15
38
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
16
39
|
console.log(indigo(`Local: ${chalk.green(localUrl)}`));
|
|
17
|
-
if (
|
|
18
|
-
|
|
40
|
+
if (networkUrls.length) {
|
|
41
|
+
networkUrls.forEach((url) => {
|
|
19
42
|
console.log(indigo(`Network: ${chalk.green(url)}`));
|
|
20
43
|
});
|
|
21
44
|
}
|
|
45
|
+
else {
|
|
46
|
+
console.log(indigo(`Network: ${chalk.dim("not available")}`));
|
|
47
|
+
}
|
|
22
48
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
23
49
|
console.log("");
|
|
24
50
|
});
|
package/package.json
CHANGED
|
@@ -12,6 +12,46 @@ import { logError, logInfo } from "../utils/logger.js";
|
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
13
|
const __dirname = path.dirname(__filename);
|
|
14
14
|
|
|
15
|
+
const GITIGNORE_CONTENT = `# Dependencies
|
|
16
|
+
node_modules/
|
|
17
|
+
dist/
|
|
18
|
+
dist-ssr/
|
|
19
|
+
|
|
20
|
+
# Vite cache
|
|
21
|
+
.vite/
|
|
22
|
+
*.local
|
|
23
|
+
|
|
24
|
+
# Environment files
|
|
25
|
+
.env
|
|
26
|
+
.env.local
|
|
27
|
+
.env.development.local
|
|
28
|
+
.env.test.local
|
|
29
|
+
.env.production.local
|
|
30
|
+
|
|
31
|
+
# Logs
|
|
32
|
+
npm-debug.log*
|
|
33
|
+
yarn-debug.log*
|
|
34
|
+
yarn-error.log*
|
|
35
|
+
|
|
36
|
+
# Editor/IDE
|
|
37
|
+
.vscode/
|
|
38
|
+
.idea/
|
|
39
|
+
*.swp
|
|
40
|
+
*.swo
|
|
41
|
+
|
|
42
|
+
# OS metadata
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
45
|
+
|
|
46
|
+
# TypeScript build info
|
|
47
|
+
*.tsbuildinfo
|
|
48
|
+
|
|
49
|
+
# Optional
|
|
50
|
+
.cache/
|
|
51
|
+
.tmp/
|
|
52
|
+
.sass-cache/
|
|
53
|
+
`;
|
|
54
|
+
|
|
15
55
|
export async function createProject(
|
|
16
56
|
projectName: string,
|
|
17
57
|
options: { force?: boolean }
|
|
@@ -23,13 +63,16 @@ export async function createProject(
|
|
|
23
63
|
|
|
24
64
|
try {
|
|
25
65
|
logInfo(`Creating project in ${projectDir}...`);
|
|
26
|
-
|
|
66
|
+
|
|
27
67
|
// Ensure the project directory exists
|
|
28
68
|
await fs.ensureDir(projectDir);
|
|
29
|
-
|
|
69
|
+
|
|
30
70
|
// This copies everything, including hidden directories like .revine
|
|
31
71
|
await copyTemplate(templateDir, projectDir, options.force);
|
|
32
72
|
|
|
73
|
+
// Explicitly write .gitignore because npm strips it from published tarballs
|
|
74
|
+
await fs.writeFile(path.join(projectDir, ".gitignore"), GITIGNORE_CONTENT);
|
|
75
|
+
|
|
33
76
|
// Derive final project name
|
|
34
77
|
const finalProjectName = isCurrentDir
|
|
35
78
|
? path.basename(projectDir)
|
|
@@ -37,28 +80,31 @@ export async function createProject(
|
|
|
37
80
|
|
|
38
81
|
// Check if package.json exists after template copy
|
|
39
82
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
40
|
-
|
|
83
|
+
|
|
41
84
|
// Create basic package.json if it doesn't exist
|
|
42
|
-
if (!await fs.pathExists(packageJsonPath)) {
|
|
85
|
+
if (!(await fs.pathExists(packageJsonPath))) {
|
|
43
86
|
const basicPackageJson = {
|
|
44
87
|
name: finalProjectName,
|
|
45
88
|
version: "0.1.0",
|
|
46
89
|
private: true,
|
|
47
|
-
type: "module"
|
|
90
|
+
type: "module",
|
|
48
91
|
};
|
|
49
92
|
await fs.writeJSON(packageJsonPath, basicPackageJson, { spaces: 2 });
|
|
50
93
|
}
|
|
51
|
-
|
|
94
|
+
|
|
52
95
|
// Update package.json with the correct details
|
|
53
96
|
const useTailwind = await askForTailwindSetup();
|
|
54
97
|
await updatePackageJson(packageJsonPath, finalProjectName, { useTailwind });
|
|
55
98
|
|
|
56
99
|
// Check if README exists, create it if it doesn't
|
|
57
100
|
const readmePath = path.join(projectDir, "README.md");
|
|
58
|
-
if (!await fs.pathExists(readmePath)) {
|
|
59
|
-
await fs.writeFile(
|
|
101
|
+
if (!(await fs.pathExists(readmePath))) {
|
|
102
|
+
await fs.writeFile(
|
|
103
|
+
readmePath,
|
|
104
|
+
`# ${finalProjectName}\n\nCreated with Revine`
|
|
105
|
+
);
|
|
60
106
|
}
|
|
61
|
-
|
|
107
|
+
|
|
62
108
|
// Update README with the project name
|
|
63
109
|
await updateReadme(readmePath, finalProjectName);
|
|
64
110
|
|
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import os from "os";
|
|
2
3
|
import type { Plugin, ViteDevServer } from "vite";
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Reads all non-internal IPv4 addresses from the host machine's
|
|
7
|
+
* network interfaces so we can display them regardless of Vite's
|
|
8
|
+
* resolvedUrls behaviour (which can be empty when logLevel is silent).
|
|
9
|
+
*/
|
|
10
|
+
function getNetworkAddresses(): string[] {
|
|
11
|
+
const interfaces = os.networkInterfaces();
|
|
12
|
+
const addresses: string[] = [];
|
|
13
|
+
|
|
14
|
+
for (const nets of Object.values(interfaces)) {
|
|
15
|
+
if (!nets) continue;
|
|
16
|
+
for (const net of nets) {
|
|
17
|
+
// Only include external IPv4 addresses
|
|
18
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
19
|
+
addresses.push(net.address);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return addresses;
|
|
25
|
+
}
|
|
26
|
+
|
|
4
27
|
export function revineLoggerPlugin(): Plugin {
|
|
5
|
-
// custom chalk instance pointing to the indigo color
|
|
6
28
|
const indigo = chalk.hex("#6d28d9");
|
|
7
29
|
|
|
8
30
|
return {
|
|
@@ -10,20 +32,27 @@ export function revineLoggerPlugin(): Plugin {
|
|
|
10
32
|
configureServer(server: ViteDevServer) {
|
|
11
33
|
server.httpServer?.once("listening", () => {
|
|
12
34
|
const protocol = server.config.server.https ? "https" : "http";
|
|
35
|
+
const port = server.config.server.port ?? 3000;
|
|
13
36
|
const localUrl =
|
|
14
|
-
server.resolvedUrls?.local[0]
|
|
15
|
-
|
|
37
|
+
server.resolvedUrls?.local[0] ?? `${protocol}://localhost:${port}/`;
|
|
38
|
+
|
|
39
|
+
// Always derive network URLs from OS interfaces — reliable even with logLevel: silent
|
|
40
|
+
const networkUrls =
|
|
41
|
+
server.resolvedUrls?.network?.length
|
|
42
|
+
? server.resolvedUrls.network
|
|
43
|
+
: getNetworkAddresses().map((addr) => `${protocol}://${addr}:${port}/`);
|
|
16
44
|
|
|
17
|
-
// Use the 'indigo' instance in place of 'chalk.cyan'
|
|
18
45
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
19
46
|
console.log(indigo.bold("🚀 Revine Dev Server is now running!"));
|
|
20
47
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
21
48
|
console.log(indigo(`Local: ${chalk.green(localUrl)}`));
|
|
22
49
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
50
|
+
if (networkUrls.length) {
|
|
51
|
+
networkUrls.forEach((url: string) => {
|
|
25
52
|
console.log(indigo(`Network: ${chalk.green(url)}`));
|
|
26
53
|
});
|
|
54
|
+
} else {
|
|
55
|
+
console.log(indigo(`Network: ${chalk.dim("not available")}`));
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
console.log(indigo("─────────────────────────────────────────────"));
|