@duonghieu0712z/create-tauri-vue-template 0.0.23 → 0.1.0

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/files.js CHANGED
@@ -9,6 +9,9 @@ export function replaceOne(content, pattern, replacement, description) {
9
9
  if (!pattern.test(content)) {
10
10
  throw new Error(`Could not update ${description}`);
11
11
  }
12
+ if (typeof replacement === 'string') {
13
+ return content.replace(pattern, replacement);
14
+ }
12
15
  return content.replace(pattern, replacement);
13
16
  }
14
17
  export async function updateText(path, replacements) {
@@ -1,7 +1,12 @@
1
1
  import { resolve } from 'node:path';
2
2
  import { readJson, updateText, writeJson } from './files.js';
3
- import { updateReleaseWorkflow } from './release-workflow.js';
4
3
  const initialProjectVersion = '0.0.1';
4
+ function literal(value) {
5
+ return () => value;
6
+ }
7
+ function tomlString(value) {
8
+ return JSON.stringify(value);
9
+ }
5
10
  export async function renameProject(targetDir, identity) {
6
11
  const packageJsonPath = resolve(targetDir, 'package.json');
7
12
  const packageJson = await readJson(packageJsonPath);
@@ -37,26 +42,27 @@ export async function renameProject(targetDir, identity) {
37
42
  }
38
43
  await writeJson(tauriConfigPath, tauriConfig);
39
44
  await updateText(resolve(targetDir, 'index.html'), [
40
- [/<title>.*<\/title>/, `<title>${identity.appName}</title>`],
45
+ [/<title>.*<\/title>/, literal(`<title>${identity.appName}</title>`)],
46
+ ]);
47
+ await updateText(resolve(targetDir, 'README.md'), [
48
+ [/^# .+$/m, literal(`# ${identity.appName}`)],
41
49
  ]);
42
- await updateText(resolve(targetDir, 'README.md'), [[/^# .+$/m, `# ${identity.appName}`]]);
43
50
  await updateText(resolve(targetDir, 'src-tauri', 'Cargo.toml'), [
44
51
  [/^name = "([^"]+)"/m, `name = "${identity.crateName}"`],
45
52
  [/^version = "([^"]+)"/m, `version = "${initialProjectVersion}"`],
46
53
  [
47
54
  /^description = "([^"]+)"/m,
48
- `description = "${identity.description || identity.appName}"`,
55
+ literal(`description = ${tomlString(identity.description || identity.appName)}`),
49
56
  ],
50
57
  [/^(\[lib\]\s+[\s\S]*?^name = )"([^"]+)"/m, `$1"${identity.crateLibName}"`],
51
58
  ]);
52
59
  await updateText(resolve(targetDir, 'src-tauri', 'Cargo.toml'), [
53
60
  [
54
61
  /^authors = \[[^\]]*\]/m,
55
- identity.author ? `authors = ["${identity.author}"]` : 'authors = []',
62
+ literal(identity.author ? `authors = [${tomlString(identity.author)}]` : 'authors = []'),
56
63
  ],
57
64
  ]);
58
65
  await updateText(resolve(targetDir, 'src-tauri', 'src', 'main.rs'), [
59
66
  [/[a-zA-Z0-9_]+_lib::run\(\)/, `${identity.crateLibName}::run()`],
60
67
  ]);
61
- await updateReleaseWorkflow(resolve(targetDir, '.github', 'workflows', 'release.yml'), identity);
62
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duonghieu0712z/create-tauri-vue-template",
3
- "version": "0.0.23",
3
+ "version": "0.1.0",
4
4
  "description": "Create a Tauri 2 + Vue 3 desktop app from the tauri-vue-template starter.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,12 @@
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
- "template"
14
+ "template",
15
+ "!template/node_modules",
16
+ "!template/dist",
17
+ "!template/dist-ssr",
18
+ "!template/src-tauri/target",
19
+ "!template/src-tauri/gen/schemas"
15
20
  ],
16
21
  "type": "module",
17
22
  "publishConfig": {
@@ -1,13 +0,0 @@
1
- import { readFile, writeFile } from 'node:fs/promises';
2
- import { replaceOne } from './files.js';
3
- export async function updateReleaseWorkflow(path, identity) {
4
- let content = await readFile(path, 'utf8');
5
- content = replaceOne(content, /^(\s*releaseName:\s*).*$/m, `$1${identity.appName} v__VERSION__`, path);
6
- if (/^\s*releaseAssetNamePattern:\s*/m.test(content)) {
7
- content = replaceOne(content, /^(\s*releaseAssetNamePattern:\s*).*$/m, `$1${identity.packageName}_[version]_[arch][setup][ext]`, path);
8
- }
9
- else {
10
- content = replaceOne(content, /^(\s*prerelease:\s*false)$/m, `$1\n releaseAssetNamePattern: ${identity.packageName}_[version]_[arch][setup][ext]`, path);
11
- }
12
- await writeFile(path, content);
13
- }