@tomjs/create-app 0.4.3 → 0.4.5

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
@@ -4,5 +4,5 @@ import a,{renameSync as Ce}from"fs";import Oe from"os";import i from"path";impor
4
4
  Scaffolding project in ${s}...`);let Z=g||P?.name||n||"",D=t=>i.join(Ne(import.meta.url),"../..",`template-${t}`),we=D(Z),G=Z.includes("node");[we,D("config")].forEach(t=>{let r=a.readdirSync(t);for(let o of r){let p=o.startsWith("_")?o.replace("_","."):o;if(G&&!f.includes("examples")&&o.includes("stylelint"))continue;let u=i.join(s,p);M(i.join(t,o),u)}});let h=T||y(),j={name:"UserName",email:"name@github.com"};function ee(){let t=h.startsWith("@")?h.split("/")[0].substring(1):De(j.name);return`${xe||`https://github.com/${t}`}/${h.substring(h.indexOf("/")+1)}.git`}je(),G&&(Se(),ke(),Ee());let te=se(process.env.npm_config_user_agent),U=te?te.name:"npm";b.which("git")&&(b.exec(`cd ${s} && git init`),f.includes("publish")&&b.exec(`cd ${s} && git remote add origin ${ee()}`));let _=i.relative(H,s);switch(console.log(`
5
5
  Done. Now run:
6
6
  `),s!==H&&console.log(` cd ${_.includes(" ")?`"${_}"`:_}`),U){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${U} install`),console.log(` ${U} run dev`);break}function Se(){["LICENSE","README.md","README.zh_CN.md"].forEach(t=>{let r=i.join(s,t);if(!f.includes("publish")&&a.existsSync(r)){a.rmSync(r),t==="README.md"&&a.writeFileSync(r,`# ${h}
7
- `,{encoding:"utf-8"});return}if(!a.existsSync(r))return;let o=a.readFileSync(r,"utf-8").replace(new RegExp("{{pkg.name}}","g"),h).replace(new RegExp("{{user.name}}","g"),j.name).replace(new RegExp("{{user.email}}","g"),j.email);a.writeFileSync(r,o)})}function k(t,...r){["dependencies","devDependencies"].forEach(o=>{Object.keys(t[o]||{}).forEach(p=>{r.find(u=>p.includes(u))&&delete t[o][p]})})}function je(){let t=v(i.join(s,"package.json"));t.name=h,f.includes("publish")?(b.which("git")&&(j.name=ye("user.name")||Oe.userInfo().username,j.email=ye("user.email")||"",t.author=Object.assign(t.author,j)),t.repository.url=`git+${ee()}`):(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),G&&(f.includes("electron")||(k(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),f.includes("vite")&&k(t,"vite")),x(i.join(s,"package.json"),t)}function I(t,r){let o=t.lastIndexOf("."),p=t.substring(0,o)+"."+r+t.substring(o),u=i.join(s,t),d=i.join(s,p);f.includes(r)?($(u),a.existsSync(d)&&Ce(d,u)):$(d)}function ke(){if(I("tsconfig.json","test"),I("jest.config.cjs","electron"),f.includes("test"))return;a.readdirSync(s).filter(o=>o.startsWith("jest.config")||["test"].includes(o)).forEach(o=>{$(i.join(s,o))});let t=i.join(s,"package.json"),r=v(t);delete r.scripts.test,r.scripts["lint:eslint"]=r.scripts["lint:eslint"].replace(",test",""),k(r,"jest"),x(t,r)}function Ee(){if(I(".lintstagedrc.cjs","examples"),!f.includes("examples")){let o=v(i.join(s,"package.json"));o.scripts.lint=o.scripts.lint.replace(" lint:stylelint",""),o.scripts["lint:eslint"]=o.scripts["lint:eslint"].replace(",examples",""),delete o.scripts["lint:stylelint"],k(o,"stylelint"),x(i.join(s,"package.json"),o);return}let t=i.join(s,"examples");a.mkdirSync(t);let r=f.includes("electron");["vue","react"].forEach(o=>{let p=D(r?`electron-${o}`:o),u=i.join(t,o);if(!a.existsSync(p)){console.log(`${X(p)} template is not exist`);return}a.cpSync(p,u,{recursive:!0});let d=v(i.join(u,"package.json"));Object.keys(d.scripts).forEach(E=>{(E.startsWith("lint")||["prepare"].includes(E))&&delete d.scripts[E]}),k(d,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),x(i.join(u,"package.json"),d),["_lintstagedrc.cjs"].forEach(E=>{let ne=i.join(u,E);a.existsSync(ne)&&a.rmSync(ne,{recursive:!0})})}),a.writeFileSync(i.join(s,"pnpm-workspace.yaml"),`packages:
7
+ `,{encoding:"utf-8"});return}if(!a.existsSync(r))return;let o=a.readFileSync(r,"utf-8").replace(new RegExp("{{pkg.name}}","g"),h).replace(new RegExp("{{user.name}}","g"),j.name).replace(new RegExp("{{user.email}}","g"),j.email);a.writeFileSync(r,o)})}function k(t,...r){["dependencies","devDependencies"].forEach(o=>{Object.keys(t[o]||{}).forEach(p=>{r.find(u=>p.includes(u))&&delete t[o][p]})})}function je(){let t=v(i.join(s,"package.json"));t.name=h,f.includes("publish")?(b.which("git")&&(j.name=ye("user.name")||Oe.userInfo().username,j.email=ye("user.email")||"",t.author=Object.assign(t.author,j)),t.repository.url=`git+${ee()}`):(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),G&&(f.includes("electron")||(k(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),f.includes("vite")||k(t,"vite")),x(i.join(s,"package.json"),t)}function I(t,r){let o=t.lastIndexOf("."),p=t.substring(0,o)+"."+r+t.substring(o),u=i.join(s,t),d=i.join(s,p);f.includes(r)?($(u),a.existsSync(d)&&Ce(d,u)):$(d)}function ke(){if(I("tsconfig.json","test"),I("jest.config.cjs","electron"),f.includes("test"))return;a.readdirSync(s).filter(o=>o.startsWith("jest.config")||["test"].includes(o)).forEach(o=>{$(i.join(s,o))});let t=i.join(s,"package.json"),r=v(t);delete r.scripts.test,r.scripts["lint:eslint"]=r.scripts["lint:eslint"].replace(",test",""),k(r,"jest"),x(t,r)}function Ee(){if(I(".lintstagedrc.cjs","examples"),!f.includes("examples")){let o=v(i.join(s,"package.json"));o.scripts.lint=o.scripts.lint.replace(" lint:stylelint",""),o.scripts["lint:eslint"]=o.scripts["lint:eslint"].replace(",examples",""),delete o.scripts["lint:stylelint"],k(o,"stylelint"),x(i.join(s,"package.json"),o);return}let t=i.join(s,"examples");a.mkdirSync(t);let r=f.includes("electron");["vue","react"].forEach(o=>{let p=D(r?`electron-${o}`:o),u=i.join(t,o);if(!a.existsSync(p)){console.log(`${X(p)} template is not exist`);return}a.cpSync(p,u,{recursive:!0});let d=v(i.join(u,"package.json"));Object.keys(d.scripts).forEach(E=>{(E.startsWith("lint")||["prepare"].includes(E))&&delete d.scripts[E]}),k(d,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),x(i.join(u,"package.json"),d),["_lintstagedrc.cjs"].forEach(E=>{let ne=i.join(u,E);a.existsSync(ne)&&a.rmSync(ne,{recursive:!0})})}),a.writeFileSync(i.join(s,"pnpm-workspace.yaml"),`packages:
8
8
  - 'examples/*'`,{encoding:"utf-8"})}}K().then(async()=>_e().catch(e=>{e.message&&console.error(e)})).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.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "create tomjs web app",
5
5
  "keywords": [
6
6
  "tomjs",
@@ -42,6 +42,16 @@
42
42
  "access": "public",
43
43
  "registry": "https://registry.npmjs.org"
44
44
  },
45
+ "scripts": {
46
+ "dev": "tsup --watch",
47
+ "build": "tsup --minify",
48
+ "lint": "run-s lint:eslint lint:stylelint lint:prettier",
49
+ "lint:eslint": "eslint \"{src,template-*}/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
50
+ "lint:stylelint": "stylelint \"template-*/**/*.{css,scss,less,vue,html}\" --fix --cache",
51
+ "lint:prettier": "prettier --write \"{src,template-*}/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}",
52
+ "prepare": "husky install",
53
+ "npv": "npm run build && np --any-branch --no-yarn --yolo --no-publish --message \"chore: release v%s\""
54
+ },
45
55
  "dependencies": {
46
56
  "kolorist": "^1.8.0",
47
57
  "lodash-es": "^4.17.21",
@@ -70,13 +80,5 @@
70
80
  "stylelint": "^15.11.0",
71
81
  "tsup": "^8.0.1",
72
82
  "typescript": "~5.2.2"
73
- },
74
- "scripts": {
75
- "dev": "tsup --watch",
76
- "build": "tsup --minify",
77
- "lint": "run-s lint:eslint lint:stylelint lint:prettier",
78
- "lint:eslint": "eslint \"{src,template-*}/**/*.{js,cjs,ts}\" *.{js,cjs,ts} --fix --cache",
79
- "lint:stylelint": "stylelint \"template-*/**/*.{css,scss,less,vue,html}\" --fix --cache",
80
- "lint:prettier": "prettier --write \"{src,template-*}/**/*.{js,cjs,ts,json,md}\" *.{js,cjs,ts,json,md}"
81
83
  }
82
- }
84
+ }
@@ -29,7 +29,7 @@
29
29
  "@tomjs/prettier": "^1.0.6",
30
30
  "@tomjs/stylelint": "^1.1.1",
31
31
  "@tomjs/tsconfig": "^1.1.2",
32
- "@tomjs/vite-plugin-electron": "^1.3.5",
32
+ "@tomjs/vite-plugin-electron": "^1.3.6",
33
33
  "@types/node": "^18.19.3",
34
34
  "@types/react": "^18.2.43",
35
35
  "@types/react-dom": "^18.2.17",
@@ -28,7 +28,7 @@
28
28
  "@tomjs/prettier": "^1.0.6",
29
29
  "@tomjs/stylelint": "^1.1.1",
30
30
  "@tomjs/tsconfig": "^1.1.2",
31
- "@tomjs/vite-plugin-electron": "^1.3.5",
31
+ "@tomjs/vite-plugin-electron": "^1.3.6",
32
32
  "@types/node": "^18.19.3",
33
33
  "@types/shelljs": "^0.8.15",
34
34
  "@vitejs/plugin-vue": "^4.5.2",