Skip to content

Commit 7f84204

Browse files
committed
Initial script
1 parent f2ea31d commit 7f84204

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { existsSync, mkdirSync, readdirSync, lstatSync, copyFileSync, rm } from 'fs';
2+
import { join } from 'path';
3+
4+
function copyFolderSync(source, destination) {
5+
if (!existsSync(destination)) {
6+
mkdirSync(destination, { recursive: true });
7+
}
8+
9+
const items = readdirSync(source);
10+
11+
items.forEach(item => {
12+
const sourcePath = join(source, item);
13+
const destinationPath = join(destination, item);
14+
15+
if (lstatSync(sourcePath).isDirectory()) {
16+
copyFolderSync(sourcePath, destinationPath);
17+
} else {
18+
copyFileSync(sourcePath, destinationPath);
19+
}
20+
});
21+
}
22+
23+
const [,, sourceFolder, destinationFolder] = process.argv;
24+
25+
if (!sourceFolder || !destinationFolder) {
26+
console.error('Please provide both source and destination paths.');
27+
process.exit(1);
28+
}
29+
30+
// If the destination folder exists, delete the folder and its contents
31+
if (existsSync(destinationFolder)) {
32+
console.log(`Destination folder '${destinationFolder}' already exists. Deleting it...`);
33+
rm(destinationFolder, { recursive: true }, (err) => {
34+
if (err) {
35+
console.error('Error deleting destination folder:', err);
36+
process.exit(1);
37+
}
38+
});
39+
}
40+
41+
copyFolderSync(sourceFolder, destinationFolder);
42+
console.log('Folder copied successfully!');

src/ProjectTemplates/Web.ProjectTemplates/package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "project-templates",
3+
"private": true,
4+
"version": "0.1.0",
5+
"description": "Project templates dependencies",
6+
"main": "index.js",
7+
"scripts": {
8+
"copy-dependency": "node copyDependency.mjs",
9+
"copy-bootstrap": "npm run copy-bootstrap-blazor && npm run copy-bootstrap-razor-pages && npm run copy-bootstrap-starter-web",
10+
"copy-bootstrap-blazor": "npm run copy-dependency -- ./node_modules/bootstrap/dist/ ./content/BlazorWeb-CSharp/BlazorWeb-CSharp/wwwroot/lib/bootstrap",
11+
"copy-bootstrap-razor-pages": "npm run copy-dependency -- ./node_modules/bootstrap/dist/ .content/RazorPagesWeb-CSharp/wwwroot/lib/bootstrap",
12+
"copy-bootstrap-starter-web": "npm run copy-bootstrap-starter-web-csharp && npm run copy-bootstrap-starter-web-fsharp",
13+
"copy-bootstrap-starter-web-csharp": "npm run copy-dependency -- ./node_modules/bootstrap/dist/ ./content/StarterWeb-CSharp/wwwroot/lib/bootstrap",
14+
"copy-bootstrap-starter-web-fsharp": "npm run copy-dependency -- ./node_modules/bootstrap/dist/ ./content/StarterWeb-FSharp/wwwroot/lib/bootstrap"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/dotnet/aspnetcore.git"
19+
},
20+
"homepage": "https://github.com/dotnet/aspnetcore#readme",
21+
"dependencies": {
22+
"bootstrap": "^5.3.3"
23+
}
24+
}

0 commit comments

Comments
 (0)