@duonghieu0712z/create-tauri-vue-template 0.0.4 → 0.0.6
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/project.js +4 -0
- package/dist/cli/scaffold.js +18 -1
- package/dist/scripts/prepare-template.js +18 -2
- package/package.json +1 -1
- package/template/_gitignore +28 -0
- package/template/CHANGELOG.md +0 -12
package/dist/cli/project.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { readJson, updateText, writeJson } from './files.js';
|
|
3
3
|
import { updateReleaseWorkflow } from './release-workflow.js';
|
|
4
|
+
const initialProjectVersion = '0.0.1';
|
|
4
5
|
export async function renameProject(targetDir, identity) {
|
|
5
6
|
const packageJsonPath = resolve(targetDir, 'package.json');
|
|
6
7
|
const packageJson = await readJson(packageJsonPath);
|
|
7
8
|
packageJson.name = identity.packageName;
|
|
9
|
+
packageJson.version = initialProjectVersion;
|
|
8
10
|
if (identity.author) {
|
|
9
11
|
packageJson.author = identity.author;
|
|
10
12
|
}
|
|
@@ -15,6 +17,7 @@ export async function renameProject(targetDir, identity) {
|
|
|
15
17
|
const tauriConfigPath = resolve(targetDir, 'src-tauri', 'tauri.conf.json');
|
|
16
18
|
const tauriConfig = await readJson(tauriConfigPath);
|
|
17
19
|
tauriConfig.productName = identity.appName;
|
|
20
|
+
tauriConfig.version = initialProjectVersion;
|
|
18
21
|
tauriConfig.identifier = identity.identifier;
|
|
19
22
|
tauriConfig.app.windows = tauriConfig.app.windows.map((window) => ({
|
|
20
23
|
...window,
|
|
@@ -32,6 +35,7 @@ export async function renameProject(targetDir, identity) {
|
|
|
32
35
|
]);
|
|
33
36
|
await updateText(resolve(targetDir, 'src-tauri', 'Cargo.toml'), [
|
|
34
37
|
[/^name = "([^"]+)"/m, `name = "${identity.crateName}"`],
|
|
38
|
+
[/^version = "([^"]+)"/m, `version = "${initialProjectVersion}"`],
|
|
35
39
|
[/^description = "([^"]+)"/m, `description = "${identity.appName}"`],
|
|
36
40
|
[/^(\[lib\]\s+[\s\S]*?^name = )"([^"]+)"/m, `$1"${identity.crateLibName}"`],
|
|
37
41
|
]);
|
package/dist/cli/scaffold.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { access, copyFile, cp, mkdir, readdir } from 'node:fs/promises';
|
|
1
|
+
import { access, copyFile, cp, mkdir, readdir, rm } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { renameProject } from './project.js';
|
|
4
4
|
export async function ensureEmptyTarget(path) {
|
|
@@ -20,11 +20,28 @@ export async function writeEditorSettings(targetDir, packageDir) {
|
|
|
20
20
|
await mkdir(resolve(targetDir, '.vscode'), { recursive: true });
|
|
21
21
|
await copyFile(resolve(packageDir, 'assets', 'vscode-settings.json'), resolve(targetDir, '.vscode', 'settings.json'));
|
|
22
22
|
}
|
|
23
|
+
async function removeTemplateArtifacts(targetDir) {
|
|
24
|
+
await Promise.all(['CHANGELOG.md', 'Changelog.md', 'changelog.md'].map((fileName) => rm(resolve(targetDir, fileName), { force: true })));
|
|
25
|
+
}
|
|
26
|
+
async function restorePackagedGitignore(targetDir) {
|
|
27
|
+
const packagedGitignorePath = resolve(targetDir, '_gitignore');
|
|
28
|
+
try {
|
|
29
|
+
await copyFile(packagedGitignorePath, resolve(targetDir, '.gitignore'));
|
|
30
|
+
await rm(packagedGitignorePath, { force: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error.code !== 'ENOENT') {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
export async function scaffoldProject(targetDir, packageDir, identity) {
|
|
24
39
|
const templateDir = resolve(packageDir, 'template');
|
|
25
40
|
await ensureTemplate(templateDir);
|
|
26
41
|
await ensureEmptyTarget(targetDir);
|
|
27
42
|
await cp(templateDir, targetDir, { recursive: true });
|
|
43
|
+
await restorePackagedGitignore(targetDir);
|
|
44
|
+
await removeTemplateArtifacts(targetDir);
|
|
28
45
|
await writeEditorSettings(targetDir, packageDir);
|
|
29
46
|
await renameProject(targetDir, identity);
|
|
30
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createWriteStream } from 'node:fs';
|
|
3
|
-
import { cp, mkdir, readdir, rm } from 'node:fs/promises';
|
|
3
|
+
import { copyFile, cp, mkdir, readdir, rm } from 'node:fs/promises';
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
5
|
import { pipeline } from 'node:stream/promises';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
@@ -8,6 +8,8 @@ import { extract } from 'tar';
|
|
|
8
8
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
const packageDir = resolve(currentDir, '..', '..');
|
|
10
10
|
const templateDir = resolve(packageDir, 'template');
|
|
11
|
+
const templateGitignorePath = resolve(templateDir, '.gitignore');
|
|
12
|
+
const packagedGitignorePath = resolve(templateDir, '_gitignore');
|
|
11
13
|
const archivePath = resolve(packageDir, '.tmp-template.tar.gz');
|
|
12
14
|
const templateRepo = process.env.TAURI_VUE_TEMPLATE_REPO || 'duonghieu0712z/tauri-vue-template';
|
|
13
15
|
const templateRef = process.env.TAURI_VUE_TEMPLATE_REF || 'main';
|
|
@@ -22,11 +24,14 @@ const excludedPaths = new Set([
|
|
|
22
24
|
'packages',
|
|
23
25
|
'src-tauri/target',
|
|
24
26
|
]);
|
|
27
|
+
const excludedFileNames = new Set(['changelog.md']);
|
|
25
28
|
function normalizePath(path) {
|
|
26
29
|
return path.replaceAll('\\', '/');
|
|
27
30
|
}
|
|
28
31
|
function shouldInclude(relativePath) {
|
|
29
|
-
|
|
32
|
+
const normalizedPath = normalizePath(relativePath);
|
|
33
|
+
const fileName = normalizedPath.split('/').at(-1)?.toLowerCase();
|
|
34
|
+
return !excludedPaths.has(normalizedPath) && !excludedFileNames.has(fileName ?? '');
|
|
30
35
|
}
|
|
31
36
|
async function copyTemplateSource(sourceDir) {
|
|
32
37
|
await mkdir(templateDir, { recursive: true });
|
|
@@ -54,6 +59,16 @@ async function extractTemplateArchive() {
|
|
|
54
59
|
filter: (path) => shouldInclude(path.split('/').slice(1).join('/')),
|
|
55
60
|
});
|
|
56
61
|
}
|
|
62
|
+
async function stagePackagedGitignore() {
|
|
63
|
+
try {
|
|
64
|
+
await copyFile(templateGitignorePath, packagedGitignorePath);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.code !== 'ENOENT') {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
57
72
|
await rm(templateDir, { recursive: true, force: true });
|
|
58
73
|
await rm(archivePath, { force: true });
|
|
59
74
|
if (templateSourceDir) {
|
|
@@ -64,4 +79,5 @@ else {
|
|
|
64
79
|
await extractTemplateArchive();
|
|
65
80
|
await rm(archivePath, { force: true });
|
|
66
81
|
}
|
|
82
|
+
await stagePackagedGitignore();
|
|
67
83
|
console.log(`Prepared template at ${templateDir}`);
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
dist-ssr
|
|
13
|
+
*.local
|
|
14
|
+
|
|
15
|
+
# Editor directories and files
|
|
16
|
+
.vscode/*
|
|
17
|
+
!.vscode/extensions.json
|
|
18
|
+
.idea
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
25
|
+
|
|
26
|
+
*.tsbuildinfo
|
|
27
|
+
|
|
28
|
+
.eslintcache
|
package/template/CHANGELOG.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## v0.0.1 - 2026-05-23
|
|
4
|
-
|
|
5
|
-
### Added
|
|
6
|
-
|
|
7
|
-
- Initial Tauri 2 desktop application template with Vue 3, TypeScript, Vite, and Tailwind CSS 4.
|
|
8
|
-
- shadcn-vue conventions, Lucide Vue, and shared UI utilities for application interface development.
|
|
9
|
-
- Rust backend shell with Tauri command registration and generated Rust-to-TypeScript bindings through Specta.
|
|
10
|
-
- Project scripts for development, production builds, app renaming, version bumping, linting, and formatting.
|
|
11
|
-
- GitHub Actions workflows for frontend quality checks, Rust formatting and Clippy checks, and cross-platform release builds.
|
|
12
|
-
- Release packaging for macOS, Linux, and Windows through `tauri-apps/tauri-action`.
|