create-packer 1.23.0 → 1.23.2

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.
@@ -1 +1 @@
1
- export declare function createTemp(dirname: string): Promise<void>;
1
+ export declare function createTemp(dirname: string): Promise<void>;
package/bin/createTemp.js CHANGED
@@ -1,64 +1,64 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTemp = void 0;
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");
12
- const cwd = process.cwd();
13
- const command = utils_1.onGenCommand();
14
- const excludes = ['node_modules', 'yarn-error.log', 'dist'];
15
- const tempRoot = path.join(__dirname, '../template');
16
- const tempInfoList = utils_1.genTemplateInfoList(tempRoot);
17
- function copyTempFile(tempPath, output) {
18
- fsExtra.readdirSync(tempPath).map(name => {
19
- if (!excludes.includes(name)) {
20
- fsExtra.copySync(path.join(tempPath, name), path.join(output, name));
21
- }
22
- });
23
- }
24
- function createTempEnd(output) {
25
- child_process_1.spawnSync(command, ['install'], {
26
- cwd: output,
27
- stdio: 'inherit'
28
- });
29
- }
30
- async function createTemp(dirname) {
31
- 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);
51
- }
52
- const creating = ora(chalk.yellow('Creating...\n')).start();
53
- const output = path.join(cwd, isCurrent ? '' : dirname);
54
- if (!isCurrent && fs_1.existsSync(output)) {
55
- return console.log(chalk.red(`${dirname} already exists!`));
56
- }
57
- if (!isCurrent) {
58
- fsExtra.mkdirSync(output);
59
- }
60
- copyTempFile(tempInfo.src, output);
61
- createTempEnd(output);
62
- creating.succeed();
63
- }
64
- exports.createTemp = createTemp;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTemp = void 0;
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");
12
+ const cwd = process.cwd();
13
+ const command = (0, utils_1.onGenCommand)();
14
+ const excludes = ['node_modules', 'yarn-error.log', 'dist'];
15
+ const tempRoot = path.join(__dirname, '../template');
16
+ const tempInfoList = (0, utils_1.genTemplateInfoList)(tempRoot);
17
+ function copyTempFile(tempPath, output) {
18
+ fsExtra.readdirSync(tempPath).map(name => {
19
+ if (!excludes.includes(name)) {
20
+ fsExtra.copySync(path.join(tempPath, name), path.join(output, name));
21
+ }
22
+ });
23
+ }
24
+ function createTempEnd(output) {
25
+ (0, child_process_1.spawnSync)(command, ['install'], {
26
+ cwd: output,
27
+ stdio: 'inherit'
28
+ });
29
+ }
30
+ async function createTemp(dirname) {
31
+ 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);
51
+ }
52
+ const creating = ora(chalk.yellow('Creating...\n')).start();
53
+ const output = path.join(cwd, isCurrent ? '' : dirname);
54
+ if (!isCurrent && (0, fs_1.existsSync)(output)) {
55
+ return console.log(chalk.red(`${dirname} already exists!`));
56
+ }
57
+ if (!isCurrent) {
58
+ fsExtra.mkdirSync(output);
59
+ }
60
+ copyTempFile(tempInfo.src, output);
61
+ createTempEnd(output);
62
+ creating.succeed();
63
+ }
64
+ exports.createTemp = createTemp;
package/bin/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
package/bin/index.js CHANGED
@@ -1,6 +1,6 @@
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 => createTemp_1.createTemp(dirname)).parse(process.argv);
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);
@@ -1,10 +1,10 @@
1
- export declare function hasPnpm(): boolean;
2
- export declare function hasYarn(): boolean;
3
- export declare function onGenCommand(): "pnpm" | "yarn" | "npm";
4
- interface tempInfoType {
5
- name: string;
6
- src: string;
7
- children?: tempInfoType[];
8
- }
9
- export declare function genTemplateInfoList(root: string): tempInfoType[];
10
- export {};
1
+ export declare function hasPnpm(): boolean;
2
+ export declare function hasYarn(): boolean;
3
+ export declare function onGenCommand(): "pnpm" | "yarn" | "npm";
4
+ interface tempInfoType {
5
+ name: string;
6
+ src: string;
7
+ children?: tempInfoType[];
8
+ }
9
+ export declare function genTemplateInfoList(root: string): tempInfoType[];
10
+ export {};
@@ -1,70 +1,74 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.genTemplateInfoList = exports.onGenCommand = exports.hasYarn = exports.hasPnpm = void 0;
23
- const path = __importStar(require("path"));
24
- const child_process_1 = require("child_process");
25
- const fs_1 = require("fs");
26
- function hasPnpm() {
27
- try {
28
- child_process_1.execSync('pnpm --version');
29
- return true;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- exports.hasPnpm = hasPnpm;
36
- function hasYarn() {
37
- try {
38
- child_process_1.execSync('yarnpkg --version');
39
- return true;
40
- }
41
- catch {
42
- return false;
43
- }
44
- }
45
- exports.hasYarn = hasYarn;
46
- function onGenCommand() {
47
- if (hasPnpm()) {
48
- return 'pnpm';
49
- }
50
- if (hasYarn()) {
51
- return 'yarn';
52
- }
53
- return 'npm';
54
- }
55
- exports.onGenCommand = onGenCommand;
56
- function genTemplateInfoList(root) {
57
- const temps = [];
58
- fs_1.readdirSync(root, { withFileTypes: true }).forEach(o => {
59
- const src = path.join(root, o.name);
60
- if (o.isDirectory()) {
61
- temps.push({
62
- name: o.name,
63
- src,
64
- children: fs_1.existsSync(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
65
- });
66
- }
67
- });
68
- return temps;
69
- }
70
- exports.genTemplateInfoList = genTemplateInfoList;
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.genTemplateInfoList = exports.onGenCommand = exports.hasYarn = exports.hasPnpm = void 0;
27
+ const path = __importStar(require("path"));
28
+ const child_process_1 = require("child_process");
29
+ const fs_1 = require("fs");
30
+ function hasPnpm() {
31
+ try {
32
+ (0, child_process_1.execSync)('pnpm --version');
33
+ return true;
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ }
39
+ exports.hasPnpm = hasPnpm;
40
+ function hasYarn() {
41
+ try {
42
+ (0, child_process_1.execSync)('yarnpkg --version');
43
+ return true;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
49
+ exports.hasYarn = hasYarn;
50
+ function onGenCommand() {
51
+ if (hasPnpm()) {
52
+ return 'pnpm';
53
+ }
54
+ if (hasYarn()) {
55
+ return 'yarn';
56
+ }
57
+ return 'npm';
58
+ }
59
+ exports.onGenCommand = onGenCommand;
60
+ function genTemplateInfoList(root) {
61
+ const temps = [];
62
+ (0, fs_1.readdirSync)(root, { withFileTypes: true }).forEach(o => {
63
+ const src = path.join(root, o.name);
64
+ if (o.isDirectory()) {
65
+ temps.push({
66
+ name: o.name,
67
+ src,
68
+ children: (0, fs_1.existsSync)(path.join(src, 'package.json')) ? [] : genTemplateInfoList(src)
69
+ });
70
+ }
71
+ });
72
+ return temps;
73
+ }
74
+ exports.genTemplateInfoList = genTemplateInfoList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -32,7 +32,7 @@
32
32
  "commitizen": "4.3.0",
33
33
  "eslint": "7.32.0",
34
34
  "rimraf": "3.0.2",
35
- "typescript": "4.3.5"
35
+ "typescript": "5.1.6"
36
36
  },
37
37
  "config": {
38
38
  "commitizen": {
@@ -0,0 +1,27 @@
1
+ import { defineManifest } from '@crxjs/vite-plugin'
2
+ import pkgJson from './package.json'
3
+
4
+ interface argType {
5
+ mode: string
6
+ }
7
+ export default function ({ mode }: argType) {
8
+ return defineManifest({
9
+ manifest_version: 3,
10
+ name: 'Hello Extensions',
11
+ description: 'Base Level Extension',
12
+ version: pkgJson.version,
13
+ action: {
14
+ default_popup: 'src/popup/popup.html',
15
+ default_icon: 'vite.svg'
16
+ },
17
+ content_scripts: [
18
+ {
19
+ js: ['src/content_script/index.tsx'],
20
+ matches: [
21
+ 'https://developer.chrome.com/docs/extensions/*',
22
+ 'https://developer.chrome.com/docs/webstore/*'
23
+ ]
24
+ }
25
+ ]
26
+ })
27
+ }
@@ -5,5 +5,5 @@
5
5
  "moduleResolution": "Node",
6
6
  "allowSyntheticDefaultImports": true
7
7
  },
8
- "include": ["vite.config.ts"]
8
+ "include": ["vite.config.ts", "defineManifest.ts", "package.json"]
9
9
  }
@@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
3
3
  import react from '@vitejs/plugin-react'
4
4
  import checker from 'vite-plugin-checker'
5
5
  import { crx } from '@crxjs/vite-plugin'
6
+ import defineManifest from './defineManifest'
6
7
 
7
8
  // https://vitejs.dev/config/
8
9
  export default defineConfig(({ mode }) => {
@@ -24,9 +25,8 @@ export default defineConfig(({ mode }) => {
24
25
  }
25
26
  }
26
27
  }),
27
- ,
28
28
  react(),
29
- crx({ manifest: require('./manifest.json') })
29
+ crx({ manifest: defineManifest({ mode }) })
30
30
  ],
31
31
  resolve: {
32
32
  alias: {
@@ -1,19 +0,0 @@
1
- {
2
- "manifest_version": 3,
3
- "name": "Hello Extensions",
4
- "description": "Base Level Extension",
5
- "version": "1.0",
6
- "action": {
7
- "default_popup": "src/popup/popup.html",
8
- "default_icon": "vite.svg"
9
- },
10
- "content_scripts": [
11
- {
12
- "js": ["src/content_script/index.tsx"],
13
- "matches": [
14
- "https://developer.chrome.com/docs/extensions/*",
15
- "https://developer.chrome.com/docs/webstore/*"
16
- ]
17
- }
18
- ]
19
- }