@ast-grep/create-lang 0.0.2 → 0.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/index.js +11 -9
- package/package.json +2 -2
- package/template/index.d.ts +2 -2
- package/template/package.json +2 -5
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function required(s) {
|
|
|
15
15
|
}
|
|
16
16
|
// https://github.com/vitejs/vite/blob/76082e3d3033b09b02b6db64de6e36942593c753/packages/create-vite/src/index.ts#L557
|
|
17
17
|
function isValidPackageName(projectName) {
|
|
18
|
-
return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName) || 'Invalid package name';
|
|
18
|
+
return (/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName) || 'Invalid package name');
|
|
19
19
|
}
|
|
20
20
|
function askConfiguration() {
|
|
21
21
|
return (0, prompts_1.default)([
|
|
@@ -51,20 +51,22 @@ function askConfiguration() {
|
|
|
51
51
|
name: 'expandoChar',
|
|
52
52
|
message: 'Expando char used in pattern',
|
|
53
53
|
initial: '$',
|
|
54
|
-
validate:
|
|
55
|
-
return value.length === 1
|
|
56
|
-
|
|
54
|
+
validate: value => {
|
|
55
|
+
return value.length === 1
|
|
56
|
+
? true
|
|
57
|
+
: 'Expando char must be a single character';
|
|
58
|
+
},
|
|
57
59
|
},
|
|
58
60
|
{
|
|
59
61
|
type: 'confirm',
|
|
60
62
|
name: 'includeDotFiles',
|
|
61
63
|
message: 'Include gitignore and npm publish files?',
|
|
62
64
|
initial: true,
|
|
63
|
-
}
|
|
65
|
+
},
|
|
64
66
|
], {
|
|
65
67
|
onCancel: () => {
|
|
66
68
|
process.exit(1);
|
|
67
|
-
}
|
|
69
|
+
},
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
72
|
function copyTemplate(targetDir, includeDotFiles) {
|
|
@@ -72,10 +74,10 @@ function copyTemplate(targetDir, includeDotFiles) {
|
|
|
72
74
|
return promises_1.default.cp(templateDir, targetDir, {
|
|
73
75
|
recursive: true, // Copy all files and folders
|
|
74
76
|
// includes hidden files if `includeDotFiles` is true
|
|
75
|
-
filter:
|
|
77
|
+
filter: src => {
|
|
76
78
|
const basename = node_path_1.default.basename(src);
|
|
77
79
|
return includeDotFiles || !basename.startsWith('.');
|
|
78
|
-
}
|
|
80
|
+
},
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
async function renameFiles(dir, answer) {
|
|
@@ -94,7 +96,7 @@ async function renameFiles(dir, answer) {
|
|
|
94
96
|
}
|
|
95
97
|
else {
|
|
96
98
|
const content = await promises_1.default.readFile(filePath, 'utf-8');
|
|
97
|
-
const newContent = content.replace(/(\$\$[A-Z_]+\$\$)/g,
|
|
99
|
+
const newContent = content.replace(/(\$\$[A-Z_]+\$\$)/g, match => {
|
|
98
100
|
return name[match] || match;
|
|
99
101
|
});
|
|
100
102
|
await promises_1.default.writeFile(filePath, newContent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ast-grep/create-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"registry": "https://registry.npmjs.org/"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "22.
|
|
29
|
+
"@types/node": "22.14.0",
|
|
30
30
|
"@types/prompts": "^2.4.9",
|
|
31
31
|
"typescript": "^5.7.3"
|
|
32
32
|
},
|
package/template/index.d.ts
CHANGED
package/template/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"src",
|
|
19
19
|
"prebuilds"
|
|
20
20
|
],
|
|
21
|
-
"keywords": ["ast-grep"],
|
|
21
|
+
"keywords": ["ast-grep", "ast-grep-lang"],
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"dependencies": {
|
|
@@ -41,9 +41,6 @@
|
|
|
41
41
|
"registry": "https://registry.npmjs.org/"
|
|
42
42
|
},
|
|
43
43
|
"pnpm": {
|
|
44
|
-
"onlyBuiltDependencies": [
|
|
45
|
-
"$$PACKAGE_NAME$$",
|
|
46
|
-
"tree-sitter-cli"
|
|
47
|
-
]
|
|
44
|
+
"onlyBuiltDependencies": ["$$PACKAGE_NAME$$", "tree-sitter-cli"]
|
|
48
45
|
}
|
|
49
46
|
}
|