create-packer 1.18.0 → 1.19.0
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/package.json +1 -2
- package/template/cli/.eslintrc +35 -0
- package/template/cli/.gitignore +29 -0
- package/template/cli/.prettierignore +6 -0
- package/template/cli/.prettierrc.js +20 -0
- package/template/cli/LICENSE +21 -0
- package/template/cli/README.md +13 -0
- package/template/cli/commitlint.config.cjs +1 -0
- package/template/cli/package.json +50 -0
- package/template/cli/pnpm-workspace.yaml +2 -0
- package/template/cli/src/clis/createTemp.ts +62 -0
- package/template/cli/src/index.ts +9 -0
- package/template/cli/src/utils/index.ts +38 -0
- package/template/cli/template/template-1/index.ts +1 -0
- package/template/cli/tsconfig.json +19 -0
- package/template/cli/utils/pub.js +43 -0
- package/template/nx/packages/vue-lib/vite.config.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-packer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "https://github.com/kevily/create-packer",
|
|
6
6
|
"author": "1k <bug_zero@163.com>",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"ora": "5.4.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"1k-tasks": "1.0.8",
|
|
26
25
|
"@commitlint/config-conventional": "^17.6.3",
|
|
27
26
|
"@commitlint/cz-commitlint": "17.4.2",
|
|
28
27
|
"@types/fs-extra": "9.0.12",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"plugins": ["@typescript-eslint"],
|
|
4
|
+
"extends": ["eslint:recommended"],
|
|
5
|
+
"env": {
|
|
6
|
+
"browser": true,
|
|
7
|
+
"node": true
|
|
8
|
+
},
|
|
9
|
+
"parserOptions": {
|
|
10
|
+
"ecmaVersion": 2018,
|
|
11
|
+
"sourceType": "module",
|
|
12
|
+
"ecmaFeatures": {
|
|
13
|
+
"jsx": true
|
|
14
|
+
},
|
|
15
|
+
"useJSXTextNode": true
|
|
16
|
+
},
|
|
17
|
+
"rules": {
|
|
18
|
+
"@typescript-eslint/no-var-requires": 0,
|
|
19
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
20
|
+
"@typescript-eslint/no-explicit-any": 1,
|
|
21
|
+
"@typescript-eslint/no-inferrable-types": [
|
|
22
|
+
"warn",
|
|
23
|
+
{
|
|
24
|
+
"ignoreParameters": true
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
28
|
+
"@typescript-eslint/member-delimiter-style": 0,
|
|
29
|
+
"@typescript-eslint/class-name-casing": 0,
|
|
30
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
31
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
32
|
+
"semi": ["error", "never"],
|
|
33
|
+
"quotes": "off"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.js
|
|
7
|
+
|
|
8
|
+
# testing
|
|
9
|
+
coverage/
|
|
10
|
+
pnpm-lock.yaml
|
|
11
|
+
|
|
12
|
+
# production
|
|
13
|
+
build/
|
|
14
|
+
dist/
|
|
15
|
+
.vscode/*
|
|
16
|
+
!.vscode/extensions.json
|
|
17
|
+
.idea
|
|
18
|
+
.history
|
|
19
|
+
|
|
20
|
+
# misc
|
|
21
|
+
.DS_Store
|
|
22
|
+
.env.local
|
|
23
|
+
.env.development.local
|
|
24
|
+
.env.test.local
|
|
25
|
+
.env.production.local
|
|
26
|
+
|
|
27
|
+
npm-debug.log*
|
|
28
|
+
yarn-debug.log*
|
|
29
|
+
yarn-error.log*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 配置文档: https://prettier.io/docs/en/options.html
|
|
2
|
+
// ----------------------------------------------------------------------
|
|
3
|
+
module.exports = {
|
|
4
|
+
overrides: [
|
|
5
|
+
{
|
|
6
|
+
files: '.prettierrc',
|
|
7
|
+
options: { parser: 'json' }
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
printWidth: 100,
|
|
11
|
+
tabWidth: 4,
|
|
12
|
+
useTabs: false,
|
|
13
|
+
semi: false,
|
|
14
|
+
singleQuote: true,
|
|
15
|
+
trailingComma: 'none',
|
|
16
|
+
bracketSpacing: true,
|
|
17
|
+
jsxBracketSameLine: true,
|
|
18
|
+
arrowParens: 'avoid',
|
|
19
|
+
rangeStart: 0
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 1k
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": "https://github.com/kevily/create-packer",
|
|
6
|
+
"author": "1k <bug_zero@163.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"bin": "./bin/index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"login": "npm login --registry https://registry.npmjs.org",
|
|
12
|
+
"pub": "pnpm run build && pnpm run push && node ./utils/pub.js",
|
|
13
|
+
"test": "pnpm run build && rimraf ./__test__ && cd ./__test__ && node ../bin -c",
|
|
14
|
+
"build": "rimraf ./bin && tsc",
|
|
15
|
+
"commit": "git add . && cz",
|
|
16
|
+
"push": "pnpm run commit && git push"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"template",
|
|
21
|
+
"template/**/.gitignore",
|
|
22
|
+
".gitignore"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"chalk": "4.1.2",
|
|
26
|
+
"commander": "8.1.0",
|
|
27
|
+
"fs-extra": "10.0.0",
|
|
28
|
+
"inquirer": "8.1.2",
|
|
29
|
+
"lodash": "4.17.21",
|
|
30
|
+
"ora": "5.4.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@commitlint/config-conventional": "^17.6.3",
|
|
34
|
+
"@commitlint/cz-commitlint": "17.4.2",
|
|
35
|
+
"@types/fs-extra": "9.0.12",
|
|
36
|
+
"@types/inquirer": "7.3.3",
|
|
37
|
+
"@types/node": "16.4.7",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "4.29.2",
|
|
39
|
+
"@typescript-eslint/parser": "4.29.2",
|
|
40
|
+
"commitizen": "4.3.0",
|
|
41
|
+
"eslint": "7.32.0",
|
|
42
|
+
"rimraf": "3.0.2",
|
|
43
|
+
"typescript": "4.3.5"
|
|
44
|
+
},
|
|
45
|
+
"config": {
|
|
46
|
+
"commitizen": {
|
|
47
|
+
"path": "@commitlint/cz-commitlint"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import inquirer = require('inquirer')
|
|
2
|
+
import fsExtra = require('fs-extra')
|
|
3
|
+
import path = require('path')
|
|
4
|
+
import fs = require('fs')
|
|
5
|
+
import chalk = require('chalk')
|
|
6
|
+
import ora = require('ora')
|
|
7
|
+
import { spawnSync } from 'child_process'
|
|
8
|
+
import { onGenCommand, onGetDir } from '../utils'
|
|
9
|
+
|
|
10
|
+
export interface tempInfoType {
|
|
11
|
+
name: string
|
|
12
|
+
src: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const cwd = process.cwd()
|
|
16
|
+
const command = onGenCommand()
|
|
17
|
+
const excludes = ['node_modules', 'yarn-error.log', 'dist']
|
|
18
|
+
const tempRoot = path.join(__dirname, '../../template')
|
|
19
|
+
const tempInfo: tempInfoType[] = onGetDir(tempRoot).map(name => {
|
|
20
|
+
return {
|
|
21
|
+
name,
|
|
22
|
+
src: path.join(tempRoot, name)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function copyTempFile(tempPath, output) {
|
|
27
|
+
fsExtra.readdirSync(tempPath).map(name => {
|
|
28
|
+
if (!excludes.includes(name)) {
|
|
29
|
+
fsExtra.copySync(path.join(tempPath, name), path.join(output, name))
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
function createTempEnd(output: string) {
|
|
34
|
+
spawnSync(command, ['install'], {
|
|
35
|
+
cwd: output,
|
|
36
|
+
stdio: 'inherit'
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function createTemp(dirname: string) {
|
|
41
|
+
const isCurrent = dirname === '.'
|
|
42
|
+
const { temp } = await inquirer.prompt([
|
|
43
|
+
{
|
|
44
|
+
type: 'list',
|
|
45
|
+
name: 'temp',
|
|
46
|
+
message: 'Select temp.',
|
|
47
|
+
choices: tempInfo.map(o => o.name)
|
|
48
|
+
}
|
|
49
|
+
])
|
|
50
|
+
const creating = ora(chalk.yellow('Creating...\n')).start()
|
|
51
|
+
const output = path.join(cwd, isCurrent ? '' : dirname)
|
|
52
|
+
if (!isCurrent && fs.existsSync(output)) {
|
|
53
|
+
return console.log(chalk.red(`${dirname} already exists!`))
|
|
54
|
+
}
|
|
55
|
+
if (!isCurrent) {
|
|
56
|
+
fsExtra.mkdirSync(output)
|
|
57
|
+
}
|
|
58
|
+
const tempPath = path.join(tempRoot, temp)
|
|
59
|
+
copyTempFile(tempPath, output)
|
|
60
|
+
createTempEnd(output)
|
|
61
|
+
creating.succeed()
|
|
62
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
import { readdirSync } from 'fs'
|
|
3
|
+
|
|
4
|
+
export function hasPnpm() {
|
|
5
|
+
try {
|
|
6
|
+
execSync('pnpm --version')
|
|
7
|
+
return true
|
|
8
|
+
} catch {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function hasYarn() {
|
|
13
|
+
try {
|
|
14
|
+
execSync('yarnpkg --version')
|
|
15
|
+
return true
|
|
16
|
+
} catch {
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function onGenCommand() {
|
|
21
|
+
if (hasPnpm()) {
|
|
22
|
+
return 'pnpm'
|
|
23
|
+
}
|
|
24
|
+
if (hasYarn()) {
|
|
25
|
+
return 'yarn'
|
|
26
|
+
}
|
|
27
|
+
return 'npm'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function onGetDir(root: string) {
|
|
31
|
+
const dirs: string[] = []
|
|
32
|
+
readdirSync(root, { withFileTypes: true }).forEach(o => {
|
|
33
|
+
if (o.isDirectory()) {
|
|
34
|
+
dirs.push(o.name)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
return dirs
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('template-1')
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"allowSyntheticDefaultImports": false,
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"target": "ESNext",
|
|
9
|
+
"noImplicitAny": false,
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"sourceMap": false,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"outDir": "bin",
|
|
14
|
+
"baseUrl": ".",
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules/**"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const inquirer = require('inquirer')
|
|
2
|
+
const currentVersion = require('../package.json').version
|
|
3
|
+
const { execSync } = require('child_process')
|
|
4
|
+
const chalk = require('chalk')
|
|
5
|
+
|
|
6
|
+
function genPrompt(nextVersion) {
|
|
7
|
+
const version = {
|
|
8
|
+
major: 0,
|
|
9
|
+
minor: 1,
|
|
10
|
+
patch: 2
|
|
11
|
+
}
|
|
12
|
+
const nextVersionIndex = version[nextVersion]
|
|
13
|
+
const newVersion = currentVersion.split('.').map(Number)
|
|
14
|
+
newVersion[nextVersionIndex] += 1
|
|
15
|
+
// 把后续的版本号归零
|
|
16
|
+
// ------------------------------------------------------------------------
|
|
17
|
+
for (let i = nextVersionIndex + 1; i < 3; i++) {
|
|
18
|
+
newVersion[i] = 0
|
|
19
|
+
}
|
|
20
|
+
return `${nextVersion}(${newVersion.join('.')})`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const versions = {
|
|
24
|
+
[genPrompt('patch')]: 'patch',
|
|
25
|
+
[genPrompt('minor')]: 'minor',
|
|
26
|
+
[genPrompt('major')]: 'major'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inquirer
|
|
30
|
+
.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: 'list',
|
|
33
|
+
name: 'version',
|
|
34
|
+
message: 'version:',
|
|
35
|
+
choices: Object.keys(versions)
|
|
36
|
+
}
|
|
37
|
+
])
|
|
38
|
+
.then(({ version }) => {
|
|
39
|
+
execSync(
|
|
40
|
+
`npm version ${versions[version]} && pnpm publish --registry https://registry.npmjs.org && git push`
|
|
41
|
+
)
|
|
42
|
+
console.log(chalk.blue('Published(*^3^)'))
|
|
43
|
+
})
|
|
@@ -6,7 +6,7 @@ import dts from 'vite-plugin-dts'
|
|
|
6
6
|
import { joinPathFragments } from '@nx/devkit'
|
|
7
7
|
|
|
8
8
|
export default defineConfig({
|
|
9
|
-
cacheDir: '../../node_modules/.vite/
|
|
9
|
+
cacheDir: '../../node_modules/.vite/vue-lib',
|
|
10
10
|
|
|
11
11
|
plugins: [
|
|
12
12
|
dts({
|
|
@@ -35,7 +35,7 @@ export default defineConfig({
|
|
|
35
35
|
lib: {
|
|
36
36
|
// Could also be a dictionary or array of multiple entry points.
|
|
37
37
|
entry: 'src/index.ts',
|
|
38
|
-
name: '
|
|
38
|
+
name: 'vue-lib',
|
|
39
39
|
fileName: 'index',
|
|
40
40
|
// Change this to the formats you want to support.
|
|
41
41
|
// Don't forgot to update your package.json as well.
|