@tomjs/create-app 0.0.22 → 0.0.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/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import l from"fs";import a from"path";import{fileURLToPath as K}from"url";import{blue as w,cyan as q,green as B,red as T,reset as p,yellow as $}from"kolorist";import G from"minimist";import H from"prompts";import s from"fs";import d from"path";function b(e){return[["t","template"]].forEach(([t,n])=>{e[n]=e[n]??e[t]}),e}function C(e){let t=s.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function y(e){return e?.trim().replace(/\/+$/g,"")}function J(e,t){s.mkdirSync(t,{recursive:!0});for(let n of s.readdirSync(e)){let m=d.resolve(e,n),g=d.resolve(t,n);v(m,g)}}function v(e,t){s.statSync(e).isDirectory()?J(e,t):s.copyFileSync(e,t)}function E(e){if(s.existsSync(e))for(let t of s.readdirSync(e))t!==".git"&&s.rmSync(d.resolve(e,t),{recursive:!0,force:!0})}function k(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function A(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function D(e){if(!e)return;let n=e.split(" ")[0].split("/");return{name:n[0],version:n[1]}}var S=b(G(process.argv.slice(2),{string:["_"]})),F=process.cwd(),V=[{name:"vue",display:"Vue",color:B,variants:[{name:"vue",display:"Web",color:w},{name:"electron-vue",display:"Electron",color:$}]},{name:"react",display:"React",color:q,variants:[{name:"react",display:"Web",color:w},{name:"electron-react",display:"Electron",color:$}]},{name:"node",display:"Node",color:w}],R=V.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),Q={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},h="my-app";async function X(){let e=y(S._[0]),t=S.template||S.t,n=e||h,m=()=>n==="."?a.basename(a.resolve()):n,g={};g=await H([{type:e?null:"text",name:"projectName",message:p("Project name:"),initial:h,onState:r=>{n=y(r.value)||h}},{type:()=>!l.existsSync(n)||C(n)?null:"toggle",name:"overwrite",message:()=>(n==="."?"Current directory":`Target directory "${n}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"yes",inactive:"no"},{type:(r,{overwrite:o})=>{if(o===!1)throw console.log(T("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>k(m())?null:"text",name:"packageName",message:p("Package name:"),initial:()=>A(m()),validate:r=>k(r)||"Invalid package.json name"},{type:t&&R.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!R.includes(t)?p(`"${t}" isn't a valid template. Please choose from below: `):p("Select a framework:"),initial:0,choices:V.map(r=>{let o=r.color;return{title:o(r.display||r.name),value:r}})},{type:r=>r&&r.variants?"select":null,name:"variant",message:p("Select a variant:"),choices:r=>r?.variants?.map(o=>{let c=o.color;return{title:c(o.display||o.name),value:o.name}})}],{onCancel:()=>{throw console.log(T("\u2716")+" Operation cancelled"),new Error}});let{framework:z,overwrite:O,packageName:L,variant:M}=g,i=a.join(F,n);O?E(i):l.existsSync(i)||l.mkdirSync(i,{recursive:!0}),console.log(`
3
- Scaffolding project in ${i}...`);let j=M||z?.name||t||"",x=r=>a.join(K(import.meta.url),"../..",`template-${r}`),N=x(j),U=j.includes("node");[N,x("config")].forEach(r=>{let o=l.readdirSync(r);for(let c of o){let W=Q[c]??c;if(U&&c.includes("stylelint"))continue;let I=a.join(i,W);v(a.join(r,c),I)}});let P=JSON.parse(l.readFileSync(a.join(N,"package.json"),"utf-8"));P.name=L||m(),l.writeFileSync(a.join(i,"package.json"),JSON.stringify(P,null,2)+`
4
- `);let _=D(process.env.npm_config_user_agent),u=_?_.name:"npm",f=a.relative(F,i);switch(console.log(`
2
+ import s from"fs";import i from"path";import{fileURLToPath as Q}from"url";import{blue as d,cyan as X,green as Y,red as z,reset as g,yellow as j}from"kolorist";import Z from"minimist";import ee from"prompts";import M from"shelljs";import l from"fs";import w from"path";function C(e){return[["t","template"]].forEach(([t,r])=>{e[r]=e[r]??e[t]}),e}function D(e){let t=l.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function S(e){return e?.trim().replace(/\/+$/g,"")}function B(e,t){l.mkdirSync(t,{recursive:!0});for(let r of l.readdirSync(e)){let m=w.resolve(e,r),f=w.resolve(t,r);h(m,f)}}function h(e,t){l.statSync(e).isDirectory()?B(e,t):l.copyFileSync(e,t)}function R(e){if(l.existsSync(e))for(let t of l.readdirSync(e))t!==".git"&&l.rmSync(w.resolve(e,t),{recursive:!0,force:!0})}function F(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function T(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function V(e){if(!e)return;let r=e.split(" ")[0].split("/");return{name:r[0],version:r[1]}}var N=C(Z(process.argv.slice(2),{string:["_"]})),x=process.cwd(),L=[{name:"vue",display:"Vue",color:Y,variants:[{name:"vue",display:"Web",color:d},{name:"electron-vue",display:"Electron",color:j}]},{name:"react",display:"React",color:X,variants:[{name:"react",display:"Web",color:d},{name:"electron-react",display:"Electron",color:j}]},{name:"node",display:"Node",color:d,variants:[{name:"node",display:"base",color:d},{name:"node-github",display:"Github + NPM",color:j}]}],O=L.map(e=>e.variants&&e.variants.map(t=>t.name)||[e.name]).reduce((e,t)=>e.concat(t),[]),te={_gitignore:".gitignore","_lintstagedrc.cjs":".lintstagedrc.cjs"},b="my-app";async function ne(){let e=S(N._[0]),t=N.template||N.t,r=e||b,m=()=>r==="."?i.basename(i.resolve()):r,f={name:"",email:""},E={};E=await ee([{type:e?null:"text",name:"projectName",message:g("Project name:"),initial:b,onState:n=>{r=S(n.value)||b}},{type:()=>!s.existsSync(r)||D(r)?null:"toggle",name:"overwrite",message:()=>(r==="."?"Current directory":`Target directory "${r}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"yes",inactive:"no"},{type:(n,{overwrite:o})=>{if(o===!1)throw console.log(z("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>F(m())?null:"text",name:"packageName",message:g("Package name:"),initial:()=>T(m()),validate:n=>F(n)||"Invalid package.json name"},{type:t&&O.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!O.includes(t)?g(`"${t}" isn't a valid template. Please choose from below: `):g("Select a framework:"),initial:0,choices:L.map(n=>{let o=n.color;return{title:o(n.display||n.name),value:n}})},{type:n=>n&&n.variants?"select":null,name:"variant",message:g("Select a variant:"),choices:n=>n?.variants?.map(o=>{let c=o.color;return{title:c(o.display||o.name),value:o.name}})}],{onCancel:()=>{throw console.log(z("\u2716")+" Operation cancelled"),new Error}});let{framework:U,overwrite:W,packageName:G,variant:I}=E,a=i.join(x,r);W?R(a):s.existsSync(a)||s.mkdirSync(a,{recursive:!0}),console.log(`
3
+ Scaffolding project in ${a}...`);let u=I||U?.name||t||"",P=n=>i.join(Q(import.meta.url),"../..",`template-${n}`),_=P(u),J=u.includes("node");[_,P("config")].forEach(n=>{let o=s.readdirSync(n);for(let c of o){let K=te[c]??c;if(J&&c.includes("stylelint"))continue;let q=i.join(a,K);h(i.join(n,c),q)}});let $=u.includes("github"),H=`template-${u}`,p=JSON.parse(s.readFileSync(i.join(_,"package.json"),"utf-8")),y=G||m();p.name=y,$&&(p.name=`@tomjs/${y}`,p.author=Object.assign(p.author,f)),s.writeFileSync(i.join(a,"package.json"),JSON.stringify(p,null,2)+`
4
+ `),$&&["package.json","README.md","README.zh_CN.md"].forEach(n=>{let o=i.join(a,n);if(s.existsSync(o)){let c=s.readFileSync(o,"utf-8");s.writeFileSync(o,c.replace(new RegExp(H,"g"),y))}});let A=V(process.env.npm_config_user_agent),v=A?A.name:"npm";M.which("git")&&M.exec(`cd ${a} && git init`);let k=i.relative(x,a);switch(console.log(`
5
5
  Done. Now run:
6
- `),i!==F&&console.log(` cd ${f.includes(" ")?`"${f}"`:f}`),u){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${u} install`),console.log(` ${u} run dev`);break}}X().catch(e=>{e.message&&console.error(e)});
6
+ `),a!==x&&console.log(` cd ${k.includes(" ")?`"${k}"`:k}`),v){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${v} install`),console.log(` ${v} run dev`);break}}ne().catch(e=>{e.message&&console.error(e)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomjs/create-app",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "create tomjs web app",
5
5
  "keywords": [
6
6
  "tomjs",
@@ -38,7 +38,8 @@
38
38
  "dependencies": {
39
39
  "kolorist": "^1.8.0",
40
40
  "minimist": "^1.2.8",
41
- "prompts": "^2.4.2"
41
+ "prompts": "^2.4.2",
42
+ "shelljs": "^0.8.5"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@commitlint/cli": "^18.4.3",
@@ -49,10 +50,11 @@
49
50
  "@types/minimist": "^1.2.5",
50
51
  "@types/node": "^18.18.13",
51
52
  "@types/prompts": "^2.4.9",
53
+ "@types/shelljs": "^0.8.15",
52
54
  "eslint": "^8.54.0",
53
55
  "husky": "^8.0.3",
54
56
  "lint-staged": "^15.1.0",
55
- "np": "^8.0.4",
57
+ "np": "^9.0.0",
56
58
  "npm-run-all": "^4.1.5",
57
59
  "prettier": "^3.1.0",
58
60
  "tsup": "^8.0.1",
@@ -49,7 +49,7 @@
49
49
  "shelljs": "^0.8.5",
50
50
  "stylelint": "^15.11.0",
51
51
  "tree-kill": "^1.2.2",
52
- "tsx": "^4.5.0",
52
+ "tsx": "^4.6.0",
53
53
  "typescript": "~5.2.2",
54
54
  "vite": "^5.0.2",
55
55
  "vite-plugin-electron": "^0.15.4",
@@ -45,7 +45,7 @@
45
45
  "shelljs": "^0.8.5",
46
46
  "stylelint": "^15.11.0",
47
47
  "tree-kill": "^1.2.2",
48
- "tsx": "^4.5.0",
48
+ "tsx": "^4.6.0",
49
49
  "typescript": "~5.2.2",
50
50
  "vite": "^5.0.2",
51
51
  "vite-plugin-electron": "^0.15.4",
@@ -1,5 +1,3 @@
1
1
  # node
2
2
 
3
- Basic node template
4
-
5
- **English** | [中文](./README.zh_CN.md)
3
+ Basic node template
@@ -5,25 +5,12 @@
5
5
  "keywords": [
6
6
  "tomjs"
7
7
  ],
8
- "author": {
9
- "name": "Tom Gao",
10
- "email": "tom@tomgao.cc"
11
- },
12
- "license": "MIT",
13
8
  "engines": {
14
9
  "node": ">=16"
15
10
  },
16
11
  "files": [
17
12
  "dist"
18
13
  ],
19
- "publishConfig": {
20
- "access": "public",
21
- "registry": "https://registry.npmjs.org/"
22
- },
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/tomgao365/template-node.git"
26
- },
27
14
  "main": "./dist/index.js",
28
15
  "module": "./dist/index.mjs",
29
16
  "types": "./dist/index.d.ts",
@@ -60,7 +47,7 @@
60
47
  "prettier": "^3.1.0",
61
48
  "rimraf": "^5.0.5",
62
49
  "tsup": "^8.0.1",
63
- "tsx": "^4.5.0",
50
+ "tsx": "^4.6.0",
64
51
  "typescript": "~5.2.2"
65
52
  }
66
53
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ },
6
+ extends: [require.resolve('@tomjs/eslint/typescript')],
7
+ };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Tom Gao <tom@tomgao.cc>
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,27 @@
1
+ # @tomjs/template-node-github
2
+
3
+ ![npm](https://img.shields.io/npm/v/%40tomjs/template-node-github) ![NPM](https://img.shields.io/npm/l/%40tomjs%2Ftemplate-node-github) ![npm package minimized gzipped size (scoped version select exports)](https://img.shields.io/bundlejs/size/%40tomjs/template-node-github)
4
+
5
+ Basic node template
6
+
7
+ **English** | [中文](./README.zh_CN.md)
8
+
9
+ ## Install
10
+
11
+ With `pnpm`
12
+
13
+ ```bash
14
+ pnpm add @tomjs/template-node-github
15
+ ```
16
+
17
+ With `yarn`
18
+
19
+ ```bash
20
+ yarn add @tomjs/template-node-github
21
+ ```
22
+
23
+ With `npm`
24
+
25
+ ```bash
26
+ npm i @tomjs/template-node-github
27
+ ```
@@ -0,0 +1,27 @@
1
+ # @tomjs/template-node-github
2
+
3
+ ![npm](https://img.shields.io/npm/v/%40tomjs/template-node-github) ![NPM](https://img.shields.io/npm/l/%40tomjs%2Ftemplate-node-github) ![npm package minimized gzipped size (scoped version select exports)](https://img.shields.io/bundlejs/size/%40tomjs/template-node-github)
4
+
5
+ 基础 node 模板
6
+
7
+ [English](./README.md) | **中文**
8
+
9
+ ## 安装
10
+
11
+ 使用 `pnpm`
12
+
13
+ ```bash
14
+ pnpm add @tomjs/template-node-github
15
+ ```
16
+
17
+ 使用 `yarn`
18
+
19
+ ```bash
20
+ yarn add @tomjs/template-node-github
21
+ ```
22
+
23
+ 使用 `npm`
24
+
25
+ ```bash
26
+ npm i @tomjs/template-node-github
27
+ ```
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '*.{js,cjs,ts}': ['eslint --fix', 'prettier --write'],
3
+ '*.{json,md}': ['prettier --write'],
4
+ };
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@tomjs/template-node-github",
3
+ "version": "0.0.0",
4
+ "description": "basic node.js template",
5
+ "keywords": [
6
+ "tomjs"
7
+ ],
8
+ "author": {
9
+ "name": "Tom Gao",
10
+ "email": "tom@tomgao.cc"
11
+ },
12
+ "license": "MIT",
13
+ "engines": {
14
+ "node": ">=16"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org/"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/tomgao365/template-node-github.git"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.mjs",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "require": "./dist/index.js",
33
+ "import": "./dist/index.mjs",
34
+ "types": "./dist/index.d.ts"
35
+ }
36
+ },
37
+ "scripts": {
38
+ "dev": "tsup --watch",
39
+ "start": "tsx ./src/index.ts",
40
+ "build": "tsup",
41
+ "lint": "run-s lint:eslint lint:prettier",
42
+ "lint:eslint": "eslint \"src/**/*.ts\" *.{js,cjs,ts} --fix --cache",
43
+ "lint:prettier": "prettier --write .",
44
+ "prepare": "husky install",
45
+ "prepublishOnly": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
46
+ },
47
+ "dependencies": {
48
+ "kolorist": "^1.8.0"
49
+ },
50
+ "devDependencies": {
51
+ "@commitlint/cli": "^18.4.3",
52
+ "@tomjs/commitlint": "^2.0.3",
53
+ "@tomjs/eslint": "^1.0.8",
54
+ "@tomjs/prettier": "^1.0.5",
55
+ "@tomjs/tsconfig": "^1.0.7",
56
+ "@types/node": "^18.18.13",
57
+ "eslint": "^8.54.0",
58
+ "husky": "^8.0.3",
59
+ "lint-staged": "^15.1.0",
60
+ "np": "^9.0.0",
61
+ "npm-run-all": "^4.1.5",
62
+ "prettier": "^3.1.0",
63
+ "rimraf": "^5.0.5",
64
+ "tsup": "^8.0.1",
65
+ "tsx": "^4.6.0",
66
+ "typescript": "~5.2.2"
67
+ }
68
+ }
@@ -0,0 +1,14 @@
1
+ import os from 'node:os';
2
+ import { blue } from 'kolorist';
3
+
4
+ function run() {
5
+ console.log(blue('Hello World!'));
6
+ console.log(
7
+ `system: ${os.platform()} ${os.arch()} v${os.release()} ${os.cpus().length} cores ${Math.ceil(
8
+ os.totalmem() / 1024 / 1024 / 1024,
9
+ )}GB`,
10
+ );
11
+ console.log(`node: ${process.version} ${process.arch}`);
12
+ }
13
+
14
+ run();
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@tomjs/tsconfig/node.json",
3
+ "include": [
4
+ "src/**/*.ts",
5
+ "src/**/*.d.ts"
6
+ ],
7
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm', 'cjs'],
6
+ target: ['es2021', 'node16'],
7
+ clean: true,
8
+ dts: true,
9
+ sourcemap: false,
10
+ splitting: true,
11
+ });