Skip to content

Commit c651ffe

Browse files
fix: missing template-blank-vue-ts afterCreate hooks (#184)
* handle hooks in gitignore * add after-createProject.js * Update package.json Co-authored-by: Igor Randjelovic <[email protected]>
1 parent 1b3e436 commit c651ffe

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

packages/template-blank-vue-ts/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
node_modules
66

77
# NativeScript application
8-
hooks
8+
hooks/*
9+
!hooks/after-createProject/after-createProject.js
910
platforms
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
module.exports = function (hookArgs) {
5+
const appRootFolder = hookArgs.projectDir;
6+
const toolsDir = path.join(appRootFolder, "tools");
7+
const vscodeDir = path.join(appRootFolder, ".vscode");
8+
const srcGitignore = path.join(toolsDir, "dot.gitignore");
9+
const destGitignore = path.join(appRootFolder, ".gitignore");
10+
const srcVscodeExtensions = path.join(toolsDir, "vscode.extensions.json");
11+
const destVscodeExtensions = path.join(vscodeDir, "extensions.json");
12+
13+
try {
14+
fs.mkdirSync(vscodeDir);
15+
fs.copyFileSync(srcVscodeExtensions, destVscodeExtensions);
16+
fs.copyFileSync(srcGitignore, destGitignore);
17+
} catch (error) {
18+
console.log(error);
19+
} finally {
20+
try {
21+
deleteFolderSync(toolsDir);
22+
23+
const readme = path.join(appRootFolder, "README.md");
24+
fs.unlinkSync(readme);
25+
26+
deleteFolderSync(__dirname);
27+
} catch (error) {
28+
console.log(error);
29+
}
30+
}
31+
32+
function deleteFolderSync(folderPath) {
33+
if (fs.statSync(folderPath).isDirectory()) {
34+
fs.readdirSync(folderPath).forEach((file) => {
35+
const content = path.join(folderPath, file);
36+
const contentDirs = fs.statSync(content).isDirectory();
37+
38+
if (contentDirs) {
39+
deleteFolderSync(content);
40+
} else {
41+
fs.unlinkSync(content);
42+
}
43+
});
44+
45+
fs.rmdirSync(folderPath);
46+
}
47+
}
48+
};

packages/template-blank-vue-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@nativescript/template-blank-vue-ts",
33
"main": "app.js",
44
"displayName": "Blank Vue Typescript",
5-
"version": "7.0.4",
5+
"version": "7.0.5",
66
"description": "Blank Typescript template for NativeScript apps using Vue.",
77
"author": "NativeScript Team <[email protected]>",
88
"license": "Apache-2.0",

0 commit comments

Comments
 (0)