UNPKG

netcore-blueprint

Version:

A custom .NET Core project blueprint

75 lines (67 loc) 2.46 kB
1. Create the blueprint - create a new project - Set up Node.js package for the blueprint + Create the folder netcore-blueprint in the root directory, and initialize a new Node.js package: mkdir netcore-blueprint cd netcore-blueprint npm init -y + Add a bin field in package.json to define the command that will execute the blueprint: "bin": { "truongdx8-netcore-blueprint": "./create.js" } + Add dependencies like fs and path if needed - Write the script to copy the Blueprint files + Create an create.js file in the netcore-blueprint directory + In create.js file, write the code to copy .NET Core template files to a new directory with the provided project name: #!/usr/bin/env node const fs = require("fs"); const path = require("path"); const projectName = process.argv[2]; if (!projectName) { console.error("Please specify the project name."); process.exit(1); } // Define paths const templatePath = path.join(__dirname, "../"); // Root of the template const destinationPath = path.join(process.cwd(), projectName); function copyTemplateFiles(src, dest) { fs.mkdirSync(dest, { recursive: true }); fs.readdirSync(src).forEach((file) => { const srcPath = path.join(src, file); const destPath = path.join(dest, file); if (fs.statSync(srcPath).isDirectory()) { copyTemplateFiles(srcPath, destPath); } else { fs.copyFileSync(srcPath, destPath); } }); } // Copy everything from the template to the new project directory copyTemplateFiles(templatePath, destinationPath); console.log(`Project ${projectName} created at ${destinationPath}`); + Make create.js executable: . chmod +x create.js + Test: node create.js innocons - Publish the Package to npm: + npm login + npm publish --access public + npm cache clean --force - Use the blueprint: + npm uninstall -g netcore-blueprint + npm install -g netcore-blueprint + npm list -g netcore-blueprint + netcore-blueprint innocons 2. Start a new project: - Git: + Add gitignore & git + Change branch name from master to main . git branch -m main . Create repo without README file . Push the first commit: git remote add origin <REMOTE_URL> git push origin main - Add routing: + Add some first components + Add routing in app-routing.module.ts - content.component: Add header & footer - Add content to each new component