create-packer 1.35.20 → 1.35.23

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/bin/createTemp.js CHANGED
@@ -1,19 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTemp = createTemp;
4
- const inquirer = require("inquirer");
5
- const fsExtra = require("fs-extra");
6
- const path = require("path");
7
- const chalk = require("chalk");
8
- const ora = require("ora");
9
- const child_process_1 = require("child_process");
10
- const utils_1 = require("./utils");
11
- const fs_1 = require("fs");
1
+ import chalk from 'chalk';
2
+ import * as inquirer from '@inquirer/prompts';
3
+ import * as fsExtra from 'fs-extra';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import ora from 'ora';
7
+ import { spawnSync } from 'child_process';
8
+ import { genTemplateInfoList, onGenCommand } from './utils/index.js';
9
+ import { existsSync } from 'fs';
12
10
  const cwd = process.cwd();
13
- const command = (0, utils_1.onGenCommand)();
11
+ const command = onGenCommand();
12
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
14
13
  const excludes = ['node_modules', 'yarn-error.log', 'dist'];
15
- const tempRoot = path.join(__dirname, '../template');
16
- const tempInfoList = (0, utils_1.genTemplateInfoList)(tempRoot);
14
+ const tempRoot = path.join(dirname, '../template');
15
+ const tempInfoList = genTemplateInfoList(tempRoot);
17
16
  function copyTempFile(tempPath, output) {
18
17
  fsExtra.readdirSync(tempPath).map(name => {
19
18
  if (!excludes.includes(name)) {
@@ -22,36 +21,28 @@ function copyTempFile(tempPath, output) {
22
21
  });
23
22
  }
24
23
  function createTempEnd(output) {
25
- (0, child_process_1.spawnSync)(command, ['install'], {
24
+ spawnSync(command, ['install'], {
26
25
  cwd: output,
27
26
  stdio: 'inherit'
28
27
  });
29
28
  }
30
- async function createTemp(dirname) {
29
+ export async function createTemp(dirname) {
31
30
  const isCurrent = dirname === '.';
32
- let answer = await inquirer.prompt([
33
- {
34
- type: 'list',
35
- name: 'temp',
36
- message: 'Select temp.',
37
- choices: tempInfoList.map(o => o.name)
38
- }
39
- ]);
40
- let tempInfo = tempInfoList.find(o => o.name === answer.temp);
31
+ let answer = await inquirer.select({
32
+ message: 'Select temp.',
33
+ choices: tempInfoList.map(o => o.name)
34
+ });
35
+ let tempInfo = tempInfoList.find(o => o.name === answer);
41
36
  if (tempInfo?.children && tempInfo.children.length > 0) {
42
- answer = await inquirer.prompt([
43
- {
44
- type: 'list',
45
- name: 'temp',
46
- message: 'Select temp type.',
47
- choices: tempInfo.children.map(o => o.name)
48
- }
49
- ]);
50
- tempInfo = tempInfo.children.find(o => o.name === answer.temp);
37
+ answer = await inquirer.select({
38
+ message: 'Select temp type.',
39
+ choices: tempInfo.children.map(o => o.name)
40
+ });
41
+ tempInfo = tempInfo.children.find(o => o.name === answer);
51
42
  }
52
43
  const creating = ora(chalk.yellow('Creating...\n')).start();
53
44
  const output = path.join(cwd, isCurrent ? '' : dirname);
54
- if (!isCurrent && (0, fs_1.existsSync)(output)) {
45
+ if (!isCurrent && existsSync(output)) {
55
46
  return console.log(chalk.red(`${dirname} already exists!`));
56
47
  }
57
48
  if (!isCurrent) {
package/bin/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const createTemp_1 = require("./createTemp");
5
- const commander_1 = require("commander");
6
- commander_1.program.argument('<dirname>', 'Create project.', dirname => (0, createTemp_1.createTemp)(dirname)).parse(process.argv);
2
+ import { createTemp } from './createTemp.js';
3
+ import { program } from 'commander';
4
+ program.argument('<dirname>', 'Create project.', dirname => createTemp(dirname)).parse(process.argv);
@@ -1,54 +1,25 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.hasPnpm = hasPnpm;
27
- exports.hasYarn = hasYarn;
28
- exports.onGenCommand = onGenCommand;
29
- exports.genTemplateInfoList = genTemplateInfoList;
30
- const path = __importStar(require("path"));
31
- const child_process_1 = require("child_process");
32
- const fs_1 = require("fs");
33
- function hasPnpm() {
1
+ import * as path from 'path';
2
+ import { execSync } from 'child_process';
3
+ import { readdirSync, existsSync } from 'fs';
4
+ export function hasPnpm() {
34
5
  try {
35
- (0, child_process_1.execSync)('pnpm --version');
6
+ execSync('pnpm --version');
36
7
  return true;
37
8
  }
38
9
  catch {
39
10
  return false;
40
11
  }
41
12
  }
42
- function hasYarn() {
13
+ export function hasYarn() {
43
14
  try {
44
- (0, child_process_1.execSync)('yarnpkg --version');
15
+ execSync('yarnpkg --version');
45
16
  return true;
46
17
  }
47
18
  catch {
48
19
  return false;
49
20
  }
50
21
  }
51
- function onGenCommand() {
22
+ export function onGenCommand() {
52
23
  if (hasPnpm()) {
53
24
  return 'pnpm';
54
25
  }
@@ -57,15 +28,15 @@ function onGenCommand() {
57
28
  }
58
29
  return 'npm';
59
30
  }
60
- function genTemplateInfoList(root) {
31
+ export function genTemplateInfoList(root) {
61
32
  const temps = [];
62
- (0, fs_1.readdirSync)(root, { withFileTypes: true }).forEach(o => {
33
+ readdirSync(root, { withFileTypes: true }).forEach(o => {
63
34
  const src = path.join(root, o.name);
64
35
  if (o.isDirectory()) {
65
36
  temps.push({
66
37
  name: o.name,
67
38
  src,
68
- children: (0, fs_1.existsSync)(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
39
+ children: existsSync(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
69
40
  });
70
41
  }
71
42
  });
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.35.20",
3
+ "version": "1.35.23",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
7
7
  "license": "MIT",
8
8
  "private": false,
9
9
  "bin": "./bin/index.js",
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
10
14
  "files": [
11
15
  "bin",
12
16
  "template",
@@ -14,12 +18,12 @@
14
18
  ".gitignore"
15
19
  ],
16
20
  "dependencies": {
17
- "chalk": "4.1.2",
21
+ "@inquirer/prompts": "7.0.0",
22
+ "chalk": "5.3.0",
18
23
  "commander": "8.1.0",
19
24
  "fs-extra": "10.0.0",
20
- "inquirer": "8.1.2",
21
25
  "lodash": "4.17.21",
22
- "ora": "5.4.1"
26
+ "ora": "8.1.0"
23
27
  },
24
28
  "devDependencies": {
25
29
  "@biomejs/biome": "1.9.2",
@@ -42,7 +46,7 @@
42
46
  },
43
47
  "scripts": {
44
48
  "login": "npm login --registry https://registry.npmjs.org",
45
- "pub": "pnpm run build && pnpm run push && node ./utils/pub.js",
49
+ "pub": "pnpm run build && pnpm run push && node ./scripts/pub.js",
46
50
  "test": "pnpm run build && rimraf ./__test__ && node ./bin __test__",
47
51
  "build": "rimraf ./bin && tsc",
48
52
  "clean:pkg": "pnpm -r exec rimraf node_modules",
@@ -7,9 +7,10 @@
7
7
  "license": "MIT",
8
8
  "private": false,
9
9
  "bin": "./bin/index.js",
10
+ "type": "module",
10
11
  "scripts": {
11
12
  "login": "npm login --registry https://registry.npmjs.org",
12
- "pub": "pnpm run build && pnpm run push && node ./utils/pub.js",
13
+ "pub": "pnpm run build && pnpm run push && node ./scripts/pub.js",
13
14
  "test": "pnpm run build && rimraf ./__test__ && node ./bin __test__",
14
15
  "build": "rimraf ./bin && tsc",
15
16
  "commit": "git add . && cz",
@@ -17,12 +18,12 @@
17
18
  },
18
19
  "files": ["bin", "template", "template/**/.gitignore", ".gitignore"],
19
20
  "dependencies": {
20
- "chalk": "4.1.2",
21
+ "@inquirer/prompts": "7.0.0",
22
+ "chalk": "5.3.0",
21
23
  "commander": "8.1.0",
22
24
  "fs-extra": "10.0.0",
23
- "inquirer": "8.1.2",
24
25
  "lodash": "4.17.21",
25
- "ora": "5.4.1"
26
+ "ora": "8.1.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@biomejs/biome": "1.9.3",
@@ -1,7 +1,7 @@
1
- const inquirer = require('inquirer')
2
- const currentVersion = require('../package.json').version
3
- const { execSync } = require('child_process')
4
- const chalk = require('chalk')
1
+ import * as inquirer from '@inquirer/prompts'
2
+ import pkg from '../package.json' assert { type: 'json' }
3
+ import { execSync } from 'child_process'
4
+ import chalk from 'chalk'
5
5
 
6
6
  function genPrompt(nextVersion) {
7
7
  const version = {
@@ -10,7 +10,7 @@ function genPrompt(nextVersion) {
10
10
  patch: 2
11
11
  }
12
12
  const nextVersionIndex = version[nextVersion]
13
- const newVersion = currentVersion.split('.').map(Number)
13
+ const newVersion = pkg.version.split('.').map(Number)
14
14
  newVersion[nextVersionIndex] += 1
15
15
  // 把后续的版本号归零
16
16
  // ------------------------------------------------------------------------
@@ -27,15 +27,11 @@ const versions = {
27
27
  }
28
28
 
29
29
  inquirer
30
- .prompt([
31
- {
32
- type: 'list',
33
- name: 'version',
34
- message: 'version:',
35
- choices: Object.keys(versions)
36
- }
37
- ])
38
- .then(({ version }) => {
30
+ .select({
31
+ message: 'version:',
32
+ choices: Object.keys(versions)
33
+ })
34
+ .then(version => {
39
35
  execSync(
40
36
  `npm version ${versions[version]} && pnpm publish --registry https://registry.npmjs.org && git push`
41
37
  )
@@ -1,16 +1,18 @@
1
- import inquirer = require('inquirer')
2
- import fsExtra = require('fs-extra')
3
- import path = require('path')
4
- import chalk = require('chalk')
5
- import ora = require('ora')
1
+ import chalk from 'chalk'
2
+ import * as inquirer from '@inquirer/prompts'
3
+ import * as fsExtra from 'fs-extra'
4
+ import path from 'path'
5
+ import { fileURLToPath } from 'url'
6
+ import ora from 'ora'
6
7
  import { spawnSync } from 'child_process'
7
- import { genTemplateInfoList, onGenCommand } from './utils'
8
+ import { genTemplateInfoList, onGenCommand } from './utils/index.js'
8
9
  import { existsSync } from 'fs'
9
10
 
10
11
  const cwd = process.cwd()
11
12
  const command = onGenCommand()
13
+ const dirname = path.dirname(fileURLToPath(import.meta.url))
12
14
  const excludes = ['node_modules', 'yarn-error.log', 'dist']
13
- const tempRoot = path.join(__dirname, '../template')
15
+ const tempRoot = path.join(dirname, '../template')
14
16
  const tempInfoList = genTemplateInfoList(tempRoot)
15
17
 
16
18
  function copyTempFile(tempPath, output) {
@@ -29,25 +31,17 @@ function createTempEnd(output: string) {
29
31
 
30
32
  export async function createTemp(dirname: string) {
31
33
  const isCurrent = dirname === '.'
32
- let answer = await inquirer.prompt([
33
- {
34
- type: 'list',
35
- name: 'temp',
36
- message: 'Select temp.',
37
- choices: tempInfoList.map(o => o.name)
38
- }
39
- ])
40
- let tempInfo = tempInfoList.find(o => o.name === answer.temp)
41
- if (tempInfo.children.length > 0) {
42
- answer = await inquirer.prompt([
43
- {
44
- type: 'list',
45
- name: 'temp',
46
- message: 'Select temp type.',
47
- choices: tempInfo.children.map(o => o.name)
48
- }
49
- ])
50
- tempInfo = tempInfo.children.find(o => o.name === answer.temp)
34
+ let answer = await inquirer.select<string>({
35
+ message: 'Select temp.',
36
+ choices: tempInfoList.map(o => o.name)
37
+ })
38
+ let tempInfo = tempInfoList.find(o => o.name === answer)
39
+ if (tempInfo?.children && tempInfo.children.length > 0) {
40
+ answer = await inquirer.select({
41
+ message: 'Select temp type.',
42
+ choices: tempInfo.children.map(o => o.name)
43
+ })
44
+ tempInfo = tempInfo.children.find(o => o.name === answer)
51
45
  }
52
46
  const creating = ora(chalk.yellow('Creating...\n')).start()
53
47
  const output = path.join(cwd, isCurrent ? '' : dirname)
@@ -57,7 +51,7 @@ export async function createTemp(dirname: string) {
57
51
  if (!isCurrent) {
58
52
  fsExtra.mkdirSync(output)
59
53
  }
60
- copyTempFile(tempInfo.src, output)
54
+ copyTempFile(tempInfo!.src, output)
61
55
  createTempEnd(output)
62
56
  creating.succeed()
63
57
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createTemp } from './createTemp'
2
+ import { createTemp } from './createTemp.js'
3
3
  import { program } from 'commander'
4
4
 
5
5
  program.argument('<dirname>', 'Create project.', dirname => createTemp(dirname)).parse(process.argv)
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "CommonJS",
3
+ "module": "NodeNext",
4
4
  "esModuleInterop": true,
5
- "allowSyntheticDefaultImports": false,
5
+ "allowSyntheticDefaultImports": true,
6
6
  "resolveJsonModule": true,
7
7
  "allowJs": true,
8
8
  "strictNullChecks": true,
9
9
  "target": "ESNext",
10
10
  "noImplicitAny": false,
11
- "moduleResolution": "node",
12
11
  "sourceMap": false,
13
12
  "declaration": true,
14
13
  "outDir": "bin",
15
14
  "baseUrl": ".",
16
15
  "skipLibCheck": true
17
16
  },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules/**"]
17
+ "include": ["src/**/*"]
20
18
  }
@@ -39,11 +39,11 @@
39
39
  "@commitlint/cli": "17.6.1",
40
40
  "@commitlint/config-conventional": "17.6.1",
41
41
  "@commitlint/cz-commitlint": "17.5.0",
42
- "@rsbuild/core": "1.0.4",
43
- "@rsbuild/plugin-eslint": "1.0.3",
44
- "@rsbuild/plugin-react": "1.0.2",
42
+ "@rsbuild/core": "1.0.10",
43
+ "@rsbuild/plugin-eslint": "1.0.4",
44
+ "@rsbuild/plugin-react": "1.0.3",
45
45
  "@rsbuild/plugin-styled-components": "1.0.1",
46
- "@rsbuild/plugin-svgr": "1.0.2",
46
+ "@rsbuild/plugin-svgr": "1.0.3",
47
47
  "@rsbuild/plugin-type-check": "1.0.1",
48
48
  "@rsdoctor/rspack-plugin": "0.4.2",
49
49
  "@types/lodash-es": "4.17.7",
@@ -11,7 +11,7 @@ import { createChunks } from './scripts/createChunks'
11
11
  export default defineConfig(({ envMode, command }) => {
12
12
  const { parsed: env } = loadEnv()
13
13
  const proxyBaseUrl = env.PUBLIC_API_HOST
14
- const publicPath = env.PUBLIC_BASE_URL
14
+ const baseUrl = env.PUBLIC_BASE_URL
15
15
  return {
16
16
  html: {
17
17
  template: './index.html'
@@ -25,11 +25,10 @@ export default defineConfig(({ envMode, command }) => {
25
25
  }
26
26
  },
27
27
  dev: {
28
- assetPrefix: publicPath,
29
28
  minify: envMode !== 'dev'
30
29
  },
31
30
  output: {
32
- assetPrefix: publicPath,
31
+ assetPrefix: baseUrl,
33
32
  distPath: {
34
33
  root: 'dist'
35
34
  },
@@ -67,15 +66,9 @@ export default defineConfig(({ envMode, command }) => {
67
66
  bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
68
67
  },
69
68
  server: {
69
+ base: baseUrl,
70
70
  host: '0.0.0.0',
71
71
  compress: false,
72
- historyApiFallback: {
73
- disableDotRule: true,
74
- index: publicPath
75
- },
76
- printUrls({ urls }) {
77
- return urls.map(url => url + publicPath)
78
- },
79
72
  proxy: [
80
73
  {
81
74
  context: [proxyBaseUrl],