@qlover/create-app 0.1.1 → 0.1.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [0.1.2](https://github.com/qlover/fe-base/compare/create-app-v0.1.1...create-app-v0.1.2) (2025-01-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add script-context ([#213](https://github.com/qlover/fe-base/issues/213)) ([e021441](https://github.com/qlover/fe-base/commit/e021441180d4c4bd89947b155d39224f89699fda))
|
|
9
|
+
|
|
3
10
|
## [0.1.1](https://github.com/qlover/fe-base/compare/create-app-v0.0.4...create-app-v0.1.1) (2025-01-15)
|
|
4
11
|
|
|
5
12
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@qlover/fe-scripts"),e=require("inquirer"),
|
|
1
|
+
"use strict";var t=require("@qlover/fe-scripts"),e=require("inquirer"),a=require("path"),r=require("ora"),s=require("fs"),i=require("ignore");const o=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,n=["node-lib","react-app","react-vite-lib"],c=[{type:"input",name:"name",message:"Project name",validate:t=>o(t,"Project name")},{type:"list",name:"template",message:"Template name",choices:[...n,"pack-app"]}],p=[{type:"checkbox",name:"subPackages",message:"Sub package names",choices:n}],{copyFile:h,stat:m}=s.promises;class l{static IGNORE_FILE=".gitignore.template";getIg(t){const e=a.join(t,l.IGNORE_FILE);if(!s.existsSync(e))return;const r=s.readFileSync(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return i().add(r)}ensureDir(t){s.existsSync(t)||s.mkdirSync(t,{recursive:!0})}async copyFilesPromise(t,e,r){const i=await s.promises.readdir(t);await Promise.all(i.map((async s=>{const i=a.join(t,s),o=a.join(e,s);if(r&&r.ignores(s))return;this.ensureDir(a.dirname(o));(await m(i)).isDirectory()?await this.copyFilesPromise(i,o,r):await h(i,o)})))}copyFilesSync(t,e,r){const i=s.readdirSync(t);for(const o of i){const i=a.join(t,o),n=a.join(e,o);r&&r.ignores(o)||(this.ensureDir(a.dirname(n)),s.statSync(i).isDirectory()?this.copyFilesSync(i,n,r):s.copyFileSync(i,n))}}create(t){const{targetPath:e,templateRootPath:r,subPackages:s,packagesNames:i="packages"}=t;if(!e||!r)throw new Error("targetPath and templatePath are required");if(this.createPath(t),s)for(const r of s){const s=a.join(e,i,r);this.createPath({...t,targetPath:s,template:r})}}async createPromise(t){const{targetPath:e,templateRootPath:r,subPackages:s,packagesNames:i="packages"}=t;if(!e||!r)throw new Error("targetPath and templatePath are required");if(await this.createPathPromise(t),s)for(const r of s){const s=a.join(e,i,r);await this.createPathPromise({...t,targetPath:s,template:r})}}createPath(t){const{targetPath:e="",templateRootPath:r,template:s}=t;this.ensureDir(e);const i=a.join(r,s),o=this.getIg(e);this.copyFilesSync(i,e,o)}createPathPromise(t){const{targetPath:e="",templateRootPath:r,template:s}=t;this.ensureDir(e);const i=a.join(r,s),o=this.getIg(e);return this.copyFilesPromise(i,e,o)}}exports.Copyer=l,exports.Generator=class{ora;context;constructor(e){const a=e.options?.templateRootPath;if(!a)throw new Error("template path not exit");if(!s.existsSync(a))throw new Error("template path not exit");this.ora=r.oraPromise,this.context=new t.FeScriptContext(e)}get logger(){return this.context.logger}async steps(t){try{return await e.prompt(t)}catch(t){throw this.logger.error(t),t}}async action({label:t,task:e}){let a=e();a instanceof Promise||(a=Promise.resolve(a));const r=t;return this.ora(a,r),a}async create(t){const e=a.join(process.cwd(),t.name),r=new l,s={...t,targetPath:e,templateRootPath:this.context.options.templateRootPath};return this.logger.debug(s),r.createPromise(s)}isPackageTemplate(t){return"pack-app"===t}async getGeneratorResult(){const t=await this.steps(c);if(this.isPackageTemplate(t.template)){const e=await this.steps(p);Object.assign(t,e)}return t}async generate(){const t=await this.getGeneratorResult();await this.action({label:"Creating project",task:()=>this.create(t)})}},exports.defaultPrompts=c,exports.packagePrompts=p,exports.validRequiredString=o;
|
package/dist/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FeScriptContext as t}from"@qlover/fe-scripts";import e from"inquirer";import{join as
|
|
1
|
+
import{FeScriptContext as t}from"@qlover/fe-scripts";import e from"inquirer";import{join as a,dirname as r}from"path";import{oraPromise as s}from"ora";import{existsSync as o,readFileSync as i,mkdirSync as c,promises as n,readdirSync as p,statSync as h,copyFileSync as m}from"fs";import l from"ignore";const g=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,P=["node-lib","react-app","react-vite-lib"],u=[{type:"input",name:"name",message:"Project name",validate:t=>g(t,"Project name")},{type:"list",name:"template",message:"Template name",choices:[...P,"pack-app"]}],f=[{type:"checkbox",name:"subPackages",message:"Sub package names",choices:P}],{copyFile:y,stat:w}=n;class k{static IGNORE_FILE=".gitignore.template";getIg(t){const e=a(t,k.IGNORE_FILE);if(!o(e))return;const r=i(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return l().add(r)}ensureDir(t){o(t)||c(t,{recursive:!0})}async copyFilesPromise(t,e,s){const o=await n.readdir(t);await Promise.all(o.map((async o=>{const i=a(t,o),c=a(e,o);if(s&&s.ignores(o))return;this.ensureDir(r(c));(await w(i)).isDirectory()?await this.copyFilesPromise(i,c,s):await y(i,c)})))}copyFilesSync(t,e,s){const o=p(t);for(const i of o){const o=a(t,i),c=a(e,i);s&&s.ignores(i)||(this.ensureDir(r(c)),h(o).isDirectory()?this.copyFilesSync(o,c,s):m(o,c))}}create(t){const{targetPath:e,templateRootPath:r,subPackages:s,packagesNames:o="packages"}=t;if(!e||!r)throw new Error("targetPath and templatePath are required");if(this.createPath(t),s)for(const r of s){const s=a(e,o,r);this.createPath({...t,targetPath:s,template:r})}}async createPromise(t){const{targetPath:e,templateRootPath:r,subPackages:s,packagesNames:o="packages"}=t;if(!e||!r)throw new Error("targetPath and templatePath are required");if(await this.createPathPromise(t),s)for(const r of s){const s=a(e,o,r);await this.createPathPromise({...t,targetPath:s,template:r})}}createPath(t){const{targetPath:e="",templateRootPath:r,template:s}=t;this.ensureDir(e);const o=a(r,s),i=this.getIg(e);this.copyFilesSync(o,e,i)}createPathPromise(t){const{targetPath:e="",templateRootPath:r,template:s}=t;this.ensureDir(e);const o=a(r,s),i=this.getIg(e);return this.copyFilesPromise(o,e,i)}}class d{ora;context;constructor(e){const a=e.options?.templateRootPath;if(!a)throw new Error("template path not exit");if(!o(a))throw new Error("template path not exit");this.ora=s,this.context=new t(e)}get logger(){return this.context.logger}async steps(t){try{return await e.prompt(t)}catch(t){throw this.logger.error(t),t}}async action({label:t,task:e}){let a=e();a instanceof Promise||(a=Promise.resolve(a));const r=t;return this.ora(a,r),a}async create(t){const e=a(process.cwd(),t.name),r=new k,s={...t,targetPath:e,templateRootPath:this.context.options.templateRootPath};return this.logger.debug(s),r.createPromise(s)}isPackageTemplate(t){return"pack-app"===t}async getGeneratorResult(){const t=await this.steps(u);if(this.isPackageTemplate(t.template)){const e=await this.steps(f);Object.assign(t,e)}return t}async generate(){const t=await this.getGeneratorResult();await this.action({label:"Creating project",task:()=>this.create(t)})}}export{k as Copyer,d as Generator,u as defaultPrompts,f as packagePrompts,g as validRequiredString};
|
package/package.json
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"main": "index.js",
|
|
2
|
+
"name": "node-lib",
|
|
3
|
+
"version": "0.0.0",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"private": true,
|
|
6
|
+
"main": "./dist/es/index.js",
|
|
7
|
+
"module": "./dist/es/index.js",
|
|
8
|
+
"types": "./dist/es/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/es/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"types": "./dist/es/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./cjs/*": "./dist/cjs/*",
|
|
16
|
+
"./es/*": "./dist/es/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"package.json",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
7
24
|
"scripts": {
|
|
8
25
|
"build": "rollup -c",
|
|
9
26
|
"test": "jest"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@qlover/fe-standard": "latest"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@qlover/fe-utils": "latest"
|
|
10
33
|
}
|
|
11
|
-
}
|
|
34
|
+
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"module": "ESNext",
|
|
4
|
-
"baseUrl": "./",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
"moduleResolution": "Bundler",
|
|
8
|
-
"target": "ES2015",
|
|
9
|
-
"downlevelIteration": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"allowUnusedLabels": false,
|
|
12
|
-
"noUnusedLocals": true,
|
|
13
|
-
"noUnusedParameters": true
|
|
14
|
-
},
|
|
2
|
+
"extends": "@qlover/fe-standard/config/tsconfig.base.json",
|
|
15
3
|
"include": ["src"],
|
|
16
4
|
"exclude": ["dist", "node_modules"]
|
|
17
5
|
}
|