@duonghieu0712z/create-tauri-vue-template 0.0.8 → 0.0.9
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/bin/index.js +7 -2
- package/dist/cli/project.js +11 -1
- package/dist/cli/prompts.js +14 -6
- package/package.json +1 -1
package/dist/bin/index.js
CHANGED
|
@@ -16,6 +16,7 @@ function parseCommand() {
|
|
|
16
16
|
.option('--package <name>', 'Package name')
|
|
17
17
|
.option('--id <identifier>', 'Tauri application identifier')
|
|
18
18
|
.option('--author <name>', 'Project author')
|
|
19
|
+
.option('--description <description>', 'Project description')
|
|
19
20
|
.help()
|
|
20
21
|
.version(packageJson.version);
|
|
21
22
|
const parsed = cli.parse(process.argv, { run: false });
|
|
@@ -33,13 +34,14 @@ function parseCommand() {
|
|
|
33
34
|
package: options.package,
|
|
34
35
|
id: options.id,
|
|
35
36
|
author: options.author,
|
|
37
|
+
description: options.description,
|
|
36
38
|
},
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
async function main() {
|
|
40
42
|
const { projectDir, options } = parseCommand();
|
|
41
43
|
if (!projectDir && !options.name && (!process.stdin.isTTY || !process.stdout.isTTY)) {
|
|
42
|
-
throw new Error('Usage: pnpm create @duonghieu0712z/tauri-vue-template@latest [project-dir] --name "My App"
|
|
44
|
+
throw new Error('Usage: pnpm create @duonghieu0712z/tauri-vue-template@latest [project-dir] --name "My App"');
|
|
43
45
|
}
|
|
44
46
|
printIntro();
|
|
45
47
|
const defaultAppName = projectDir ? toTitleCase(basename(projectDir)) : 'Tauri Vue App';
|
|
@@ -52,8 +54,10 @@ async function main() {
|
|
|
52
54
|
const targetDir = resolve(process.cwd(), targetArg);
|
|
53
55
|
const crateName = toKebabCase(packageName);
|
|
54
56
|
const crateLibName = `${toSnakeCase(crateName)}_lib`;
|
|
55
|
-
const identifier = requiredValue(resolvedOptions.id?.trim() || `com.example.${packageName}`, 'Tauri identifier');
|
|
56
57
|
const author = resolvedOptions.author?.trim();
|
|
58
|
+
const identifier = requiredValue(resolvedOptions.id?.trim() ||
|
|
59
|
+
`com.${author ? toKebabCase(author) : 'example'}.${toKebabCase(appName)}`, 'Tauri identifier');
|
|
60
|
+
const description = resolvedOptions.description?.trim();
|
|
57
61
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
58
62
|
const packageDir = resolve(currentDir, '..', '..');
|
|
59
63
|
await scaffoldProject(targetDir, packageDir, {
|
|
@@ -63,6 +67,7 @@ async function main() {
|
|
|
63
67
|
crateLibName,
|
|
64
68
|
identifier,
|
|
65
69
|
author,
|
|
70
|
+
description,
|
|
66
71
|
});
|
|
67
72
|
const relativeTargetDir = relative(process.cwd(), targetDir) || '.';
|
|
68
73
|
console.log('');
|
package/dist/cli/project.js
CHANGED
|
@@ -13,6 +13,12 @@ export async function renameProject(targetDir, identity) {
|
|
|
13
13
|
else {
|
|
14
14
|
delete packageJson.author;
|
|
15
15
|
}
|
|
16
|
+
if (identity.description) {
|
|
17
|
+
packageJson.description = identity.description;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
delete packageJson.description;
|
|
21
|
+
}
|
|
16
22
|
await writeJson(packageJsonPath, packageJson);
|
|
17
23
|
const tauriConfigPath = resolve(targetDir, 'src-tauri', 'tauri.conf.json');
|
|
18
24
|
const tauriConfig = await readJson(tauriConfigPath);
|
|
@@ -33,10 +39,14 @@ export async function renameProject(targetDir, identity) {
|
|
|
33
39
|
await updateText(resolve(targetDir, 'index.html'), [
|
|
34
40
|
[/<title>.*<\/title>/, `<title>${identity.appName}</title>`],
|
|
35
41
|
]);
|
|
42
|
+
await updateText(resolve(targetDir, 'README.md'), [[/^# .+$/m, `# ${identity.appName}`]]);
|
|
36
43
|
await updateText(resolve(targetDir, 'src-tauri', 'Cargo.toml'), [
|
|
37
44
|
[/^name = "([^"]+)"/m, `name = "${identity.crateName}"`],
|
|
38
45
|
[/^version = "([^"]+)"/m, `version = "${initialProjectVersion}"`],
|
|
39
|
-
[
|
|
46
|
+
[
|
|
47
|
+
/^description = "([^"]+)"/m,
|
|
48
|
+
`description = "${identity.description || identity.appName}"`,
|
|
49
|
+
],
|
|
40
50
|
[/^(\[lib\]\s+[\s\S]*?^name = )"([^"]+)"/m, `$1"${identity.crateLibName}"`],
|
|
41
51
|
]);
|
|
42
52
|
await updateText(resolve(targetDir, 'src-tauri', 'Cargo.toml'), [
|
package/dist/cli/prompts.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
2
|
import { formatPrompt, printSection, color } from './color.js';
|
|
3
3
|
import { toKebabCase } from './text.js';
|
|
4
|
+
function defaultIdentifier(appName, author) {
|
|
5
|
+
const owner = author ? toKebabCase(author) : 'example';
|
|
6
|
+
return `com.${owner}.${toKebabCase(appName)}`;
|
|
7
|
+
}
|
|
4
8
|
export async function promptForMissingOptions(options, defaults) {
|
|
5
9
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
6
10
|
const appName = options.name?.trim() || defaults.appName;
|
|
@@ -8,8 +12,9 @@ export async function promptForMissingOptions(options, defaults) {
|
|
|
8
12
|
return {
|
|
9
13
|
name: appName,
|
|
10
14
|
package: packageName,
|
|
11
|
-
id: options.id?.trim() ||
|
|
15
|
+
id: options.id?.trim() || defaultIdentifier(appName, options.author?.trim() || ''),
|
|
12
16
|
author: options.author?.trim() || '',
|
|
17
|
+
description: options.description?.trim() || '',
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
20
|
const prompt = createInterface({
|
|
@@ -21,21 +26,24 @@ export async function promptForMissingOptions(options, defaults) {
|
|
|
21
26
|
const appName = options.name?.trim() ||
|
|
22
27
|
(await prompt.question(formatPrompt('App name', defaults.appName))).trim() ||
|
|
23
28
|
defaults.appName;
|
|
29
|
+
const author = options.author?.trim() ||
|
|
30
|
+
(await prompt.question(`Author ${color.dim('(optional)')}: `)).trim();
|
|
24
31
|
const defaultPackageName = toKebabCase(appName);
|
|
25
32
|
const packageName = options.package?.trim() ||
|
|
26
33
|
(await prompt.question(formatPrompt('Package name', defaultPackageName))).trim() ||
|
|
27
34
|
defaultPackageName;
|
|
28
|
-
const
|
|
35
|
+
const defaultAppIdentifier = defaultIdentifier(appName, author);
|
|
29
36
|
const identifier = options.id?.trim() ||
|
|
30
|
-
(await prompt.question(formatPrompt('Tauri identifier',
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
(await prompt.question(`
|
|
37
|
+
(await prompt.question(formatPrompt('Tauri identifier', defaultAppIdentifier))).trim() ||
|
|
38
|
+
defaultAppIdentifier;
|
|
39
|
+
const description = options.description?.trim() ||
|
|
40
|
+
(await prompt.question(`Description ${color.dim('(optional)')}: `)).trim();
|
|
34
41
|
return {
|
|
35
42
|
name: appName,
|
|
36
43
|
package: packageName,
|
|
37
44
|
id: identifier,
|
|
38
45
|
author,
|
|
46
|
+
description,
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
49
|
finally {
|