vite-wp 0.1.7 → 0.1.8
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/init.js +43 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -16,6 +16,7 @@ export function runInit() {
|
|
|
16
16
|
mkdirSync(target, { recursive: true });
|
|
17
17
|
copyDirectory(starter, target, force);
|
|
18
18
|
updatePackageJson(target, packageRoot);
|
|
19
|
+
ensureGitignore(target);
|
|
19
20
|
console.log(`ViteWP project files initialized in ${relative(process.cwd(), target) || '.'}.`);
|
|
20
21
|
if (shouldInstall) {
|
|
21
22
|
installDependencies(target);
|
|
@@ -65,6 +66,48 @@ function updatePackageJson(root, packageRoot) {
|
|
|
65
66
|
packageJson.devDependencies['@astrojs/check'] ??= '^0.9.9';
|
|
66
67
|
writeFileSync(file, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8');
|
|
67
68
|
}
|
|
69
|
+
function ensureGitignore(root) {
|
|
70
|
+
const file = join(root, '.gitignore');
|
|
71
|
+
if (existsSync(file)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(file, renderGitignore(), 'utf8');
|
|
75
|
+
}
|
|
76
|
+
function renderGitignore() {
|
|
77
|
+
return `# Dependencies
|
|
78
|
+
node_modules/
|
|
79
|
+
vendor/
|
|
80
|
+
|
|
81
|
+
# Environment
|
|
82
|
+
.env
|
|
83
|
+
.env.*
|
|
84
|
+
!.env.example
|
|
85
|
+
|
|
86
|
+
# Build output
|
|
87
|
+
dist/
|
|
88
|
+
dist-ssr/
|
|
89
|
+
|
|
90
|
+
# ViteWP generated/runtime files
|
|
91
|
+
.vitewp/
|
|
92
|
+
.astro/
|
|
93
|
+
wordpress/public/
|
|
94
|
+
wordpress/content/uploads/
|
|
95
|
+
wordpress/content/debug.log
|
|
96
|
+
|
|
97
|
+
# Logs
|
|
98
|
+
logs/
|
|
99
|
+
*.log
|
|
100
|
+
npm-debug.log*
|
|
101
|
+
yarn-debug.log*
|
|
102
|
+
pnpm-debug.log*
|
|
103
|
+
|
|
104
|
+
# Editor and OS files
|
|
105
|
+
.DS_Store
|
|
106
|
+
.idea/
|
|
107
|
+
.vscode/*
|
|
108
|
+
!.vscode/extensions.json
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
68
111
|
function readOwnPackage(packageRoot) {
|
|
69
112
|
const file = join(packageRoot, 'package.json');
|
|
70
113
|
const packageJson = JSON.parse(readFileSync(file, 'utf8'));
|