create-pubinfo 0.3.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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # create-pubinfo
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![Monorepo][monorepo-src]][monorepo-href]
5
+ ![License][License-src]
6
+
7
+ > 一键生成项目模板
8
+
9
+ ## 基本用法
10
+
11
+ ```bash
12
+ npm create @pubinfo
13
+ ```
14
+
15
+ <!-- Badges -->
16
+ [npm-version-src]: https://img.shields.io/npm/v/create-pubinfo?style=flat-square
17
+ [npm-version-href]: https://npmjs.com/package/create-pubinfo
18
+ [monorepo-src]: https://img.shields.io/badge/Monorepo-with%20pnpm-F5871D.svg
19
+ [monorepo-href]: https://pnpm.io/workspaces
20
+ [License-src]: https://img.shields.io/badge/license-MIT-green
@@ -0,0 +1,52 @@
1
+ // src/download.ts
2
+ import { downloadTemplate } from "giget";
3
+ import ProgressBar from "progress";
4
+ import FackProgress from "fake-progress";
5
+ import consola from "consola";
6
+ var pubinfo = async (input, { auth }) => {
7
+ return {
8
+ name: "pubinfo",
9
+ version: input,
10
+ headers: { Authorization: `token ${auth}` },
11
+ tar: "http://124.223.184.245:10000/monorepo-project-template.tar.gz"
12
+ };
13
+ };
14
+ async function download(options = {}) {
15
+ const stop = startProgress();
16
+ try {
17
+ await downloadTemplate("pubinfo:monorepo-project-template", {
18
+ providers: { pubinfo },
19
+ force: true,
20
+ auth: options.auth,
21
+ dir: options.dir
22
+ });
23
+ } catch (error) {
24
+ consola.error(error);
25
+ }
26
+ stop();
27
+ }
28
+ function startProgress() {
29
+ const bar = new ProgressBar("Downloading [:bar] :percent", {
30
+ complete: "=",
31
+ incomplete: " ",
32
+ width: 20,
33
+ total: 100
34
+ });
35
+ const fake = new FackProgress({
36
+ timeConstant: 5 * 1e3
37
+ });
38
+ const startTime = Date.now();
39
+ fake.start();
40
+ const timer = setInterval(() => {
41
+ bar.update(fake.progress);
42
+ if (bar.complete) {
43
+ consola.success(`Download complete in ${Date.now() - startTime}ms.`);
44
+ clearInterval(timer);
45
+ }
46
+ }, 100);
47
+ return () => fake.end();
48
+ }
49
+
50
+ export {
51
+ download
52
+ };
package/dist/cli.cjs ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/cli.ts
27
+ var import_commander = require("commander");
28
+ var import_prompts = require("@inquirer/prompts");
29
+
30
+ // package.json
31
+ var package_default = {
32
+ name: "create-pubinfo",
33
+ type: "module",
34
+ version: "0.3.0",
35
+ description: "Start a Pubinfo project.",
36
+ author: "Werheng <werheng.zhang@gmail.com>",
37
+ license: "MIT",
38
+ repository: "https://github.com/werheng/pubinfo-cli",
39
+ bugs: {
40
+ url: "https://github.com/werheng/pubinfo-cli/issues"
41
+ },
42
+ bin: {
43
+ "create-pubinfo": "./dist/cli.js"
44
+ },
45
+ files: [
46
+ "dist"
47
+ ],
48
+ scripts: {
49
+ dev: "tsup --watch src",
50
+ build: "tsup"
51
+ },
52
+ dependencies: {
53
+ "@inquirer/prompts": "^4.3.1",
54
+ commander: "^12.0.0",
55
+ consola: "^3.2.3",
56
+ "fake-progress": "^1.0.4",
57
+ giget: "^1.2.3",
58
+ progress: "^2.0.3"
59
+ }
60
+ };
61
+
62
+ // src/download.ts
63
+ var import_giget = require("giget");
64
+ var import_progress = __toESM(require("progress"), 1);
65
+ var import_fake_progress = __toESM(require("fake-progress"), 1);
66
+ var import_consola = __toESM(require("consola"), 1);
67
+ var pubinfo = async (input2, { auth }) => {
68
+ return {
69
+ name: "pubinfo",
70
+ version: input2,
71
+ headers: { Authorization: `token ${auth}` },
72
+ tar: "http://124.223.184.245:10000/monorepo-project-template.tar.gz"
73
+ };
74
+ };
75
+ async function download(options = {}) {
76
+ const stop = startProgress();
77
+ try {
78
+ await (0, import_giget.downloadTemplate)("pubinfo:monorepo-project-template", {
79
+ providers: { pubinfo },
80
+ force: true,
81
+ auth: options.auth,
82
+ dir: options.dir
83
+ });
84
+ } catch (error) {
85
+ import_consola.default.error(error);
86
+ }
87
+ stop();
88
+ }
89
+ function startProgress() {
90
+ const bar = new import_progress.default("Downloading [:bar] :percent", {
91
+ complete: "=",
92
+ incomplete: " ",
93
+ width: 20,
94
+ total: 100
95
+ });
96
+ const fake = new import_fake_progress.default({
97
+ timeConstant: 5 * 1e3
98
+ });
99
+ const startTime = Date.now();
100
+ fake.start();
101
+ const timer = setInterval(() => {
102
+ bar.update(fake.progress);
103
+ if (bar.complete) {
104
+ import_consola.default.success(`Download complete in ${Date.now() - startTime}ms.`);
105
+ clearInterval(timer);
106
+ }
107
+ }, 100);
108
+ return () => fake.end();
109
+ }
110
+
111
+ // src/cli.ts
112
+ async function main() {
113
+ const program = new import_commander.Command();
114
+ program.name(package_default.name).description(package_default.description).version(package_default.version);
115
+ program.parse();
116
+ const answer = {
117
+ dir: await (0, import_prompts.input)({ message: "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0", default: "my-app" })
118
+ };
119
+ await download({
120
+ ...answer
121
+ });
122
+ }
123
+ main();
package/dist/cli.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ download
4
+ } from "./chunk-DRJ7EKPP.js";
5
+
6
+ // src/cli.ts
7
+ import { Command } from "commander";
8
+ import { input } from "@inquirer/prompts";
9
+
10
+ // package.json
11
+ var package_default = {
12
+ name: "create-pubinfo",
13
+ type: "module",
14
+ version: "0.3.0",
15
+ description: "Start a Pubinfo project.",
16
+ author: "Werheng <werheng.zhang@gmail.com>",
17
+ license: "MIT",
18
+ repository: "https://github.com/werheng/pubinfo-cli",
19
+ bugs: {
20
+ url: "https://github.com/werheng/pubinfo-cli/issues"
21
+ },
22
+ bin: {
23
+ "create-pubinfo": "./dist/cli.js"
24
+ },
25
+ files: [
26
+ "dist"
27
+ ],
28
+ scripts: {
29
+ dev: "tsup --watch src",
30
+ build: "tsup"
31
+ },
32
+ dependencies: {
33
+ "@inquirer/prompts": "^4.3.1",
34
+ commander: "^12.0.0",
35
+ consola: "^3.2.3",
36
+ "fake-progress": "^1.0.4",
37
+ giget: "^1.2.3",
38
+ progress: "^2.0.3"
39
+ }
40
+ };
41
+
42
+ // src/cli.ts
43
+ async function main() {
44
+ const program = new Command();
45
+ program.name(package_default.name).description(package_default.description).version(package_default.version);
46
+ program.parse();
47
+ const answer = {
48
+ dir: await input({ message: "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0", default: "my-app" })
49
+ };
50
+ await download({
51
+ ...answer
52
+ });
53
+ }
54
+ main();
package/dist/index.cjs ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ download: () => download
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/download.ts
38
+ var import_giget = require("giget");
39
+ var import_progress = __toESM(require("progress"), 1);
40
+ var import_fake_progress = __toESM(require("fake-progress"), 1);
41
+ var import_consola = __toESM(require("consola"), 1);
42
+ var pubinfo = async (input, { auth }) => {
43
+ return {
44
+ name: "pubinfo",
45
+ version: input,
46
+ headers: { Authorization: `token ${auth}` },
47
+ tar: "http://124.223.184.245:10000/monorepo-project-template.tar.gz"
48
+ };
49
+ };
50
+ async function download(options = {}) {
51
+ const stop = startProgress();
52
+ try {
53
+ await (0, import_giget.downloadTemplate)("pubinfo:monorepo-project-template", {
54
+ providers: { pubinfo },
55
+ force: true,
56
+ auth: options.auth,
57
+ dir: options.dir
58
+ });
59
+ } catch (error) {
60
+ import_consola.default.error(error);
61
+ }
62
+ stop();
63
+ }
64
+ function startProgress() {
65
+ const bar = new import_progress.default("Downloading [:bar] :percent", {
66
+ complete: "=",
67
+ incomplete: " ",
68
+ width: 20,
69
+ total: 100
70
+ });
71
+ const fake = new import_fake_progress.default({
72
+ timeConstant: 5 * 1e3
73
+ });
74
+ const startTime = Date.now();
75
+ fake.start();
76
+ const timer = setInterval(() => {
77
+ bar.update(fake.progress);
78
+ if (bar.complete) {
79
+ import_consola.default.success(`Download complete in ${Date.now() - startTime}ms.`);
80
+ clearInterval(timer);
81
+ }
82
+ }, 100);
83
+ return () => fake.end();
84
+ }
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ download
88
+ });
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import {
2
+ download
3
+ } from "./chunk-DRJ7EKPP.js";
4
+ export {
5
+ download
6
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "create-pubinfo",
3
+ "type": "module",
4
+ "version": "0.3.0",
5
+ "description": "Start a Pubinfo project.",
6
+ "author": "Werheng <werheng.zhang@gmail.com>",
7
+ "license": "MIT",
8
+ "repository": "https://github.com/werheng/pubinfo-cli",
9
+ "bugs": {
10
+ "url": "https://github.com/werheng/pubinfo-cli/issues"
11
+ },
12
+ "bin": {
13
+ "create-pubinfo": "./dist/cli.js"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@inquirer/prompts": "^4.3.1",
20
+ "commander": "^12.0.0",
21
+ "consola": "^3.2.3",
22
+ "fake-progress": "^1.0.4",
23
+ "giget": "^1.2.3",
24
+ "progress": "^2.0.3"
25
+ },
26
+ "scripts": {
27
+ "dev": "tsup --watch src",
28
+ "build": "tsup"
29
+ }
30
+ }