@taiyuuki/create-scaffold
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Create Scaffold

中文

Create a custom scaffold using a template.

Usage

Install

npm i @taiyuuki/create-scaffold

Create project from template

import { createProject } from '@taiyuuki/create-scaffold'

createProject(templateFolder, options)
  • templateFolder Templates directory

  • options

    • output: Project output directory, required.
    • Any variable: Variables required to compile ejs. You can use command line tools to let users enter, such as prompts.

Example

There are the following templates:

E:/template
    ├─src
    │  └─index.ts
    ├─.eslintignore
    ├─.eslintrc.js
    ├─.gitignore
    ├─.npmrc
    ├─package.json.ejs
    ├─README.md.ejs
    ├─tsconfig.json
    └─tsup.config.ts
  • Files containing variables need to add .ejs as the suffix.
  • The remaining files will be directly copied to the project directory.

Take package.json.ejs as an example:

{
  "name": "<%= projectName %>",
  "version": "0.0.1",
  "description": "<%= description %>",
  "main": "./dist/index.js",
  <% if (userName !== '') { %> 
  "repository": {
    "type": "git",
    "url": "https://github.com/<%= userName %>/<%= projectName %>"
  },
  "bugs": "https://github.com/<%= userName %>/<%= projectName %>/issues",
  "homepage": "https://github.com/<%= userName %>/<%= projectName %>#readme",
  <% } %>
  "scripts": {
    "lint": "eslint --ext .js,.ts ./",
    "dev": "tsup --watch",
    "build": "tsup"
  },
  "keywords": [],
  "author": "<%= author %>",
  "license": "MIT",
  "files": [
    "dist"
  ],
  "devDependencies": <%= devDependencies %>,
  "dependencies": {
  }
}

The variables are wrapped by <%= %>.

For more detailed EJS syntax, please refer to EJS.

Create Project:

import { createProject } from '@taiyuuki/create-scaffold'

createProject('E:/template', {
    output: 'E:/test-project',
    projectName: 'test-project',
    description: 'This is a test project.',
    userName: 'taiyuuki',
    author: 'taiyuuki <taiyuuki@qq.com>',
    devDependencies: JSON.stringify({
        '@taiyuuki/eslint-config-ts': '^0.0.5',
        '@types/node': '^18.11.18',
        'eslint': '^8.10.0',
        'tsup': '^6.4.0'
    })
})

The final project package.json is as follows.

{
  "name": "test-project",
  "version": "0.0.1",
  "description": "This is a test project.",
  "main": "./dist/index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/taiyuuki/test-project"
  },
  "bugs": "https://github.com/taiyuuki/test-project/issues",
  "homepage": "https://github.com/taiyuuki/test-project#readme",
  "scripts": {
    "lint": "eslint --ext .js,.ts ./",
    "dev": "tsup --watch",
    "build": "tsup"
  },
  "keywords": [],
  "author": "taiyuuki <taiyuuki@qq.com>",
  "license": "MIT",
  "files": [
    "dist"
  ],
  "devDependencies": {
    "@taiyuuki/eslint-config-ts": "^0.0.5",
    "@types/node": "^18.11.18",
    "eslint": "^8.10.0",
    "tsup": "^6.4.0"
  },
  "dependencies": {}
}

Readme

Keywords

none

Package Sidebar

Install

npm i @taiyuuki/create-scaffold

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

11.2 kB

Total Files

6

Last publish

Collaborators

  • taiyuuki