@qlover/create-app 0.0.3 → 0.0.4

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.0.4](https://github.com/qlover/fe-base/compare/create-app-v0.0.3...create-app-v0.0.4) (2025-01-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * .gitignore no file ([#207](https://github.com/qlover/fe-base/issues/207)) ([e61d468](https://github.com/qlover/fe-base/commit/e61d4683a072048326205272d927e7e67b87ba70))
9
+
3
10
  ## 0.0.1 (2025-01-14)
4
11
 
5
12
  ## 0.0.2 (2025-01-14)
@@ -54,14 +54,15 @@ declare class Generator {
54
54
  declare const validRequiredString: (value: string, key: string) => string | true;
55
55
 
56
56
  declare class Copyer {
57
- getIg(targetDir: string): ignore.Ignore;
57
+ static IGNORE_FILE: string;
58
+ getIg(targetDir: string): ignore.Ignore | undefined;
58
59
  /**
59
60
  * copy templates recursively
60
61
  * @param {string} templatesDir - source directory
61
62
  * @param {string} targetDir - target directory
62
63
  * @param {ignore.Ignore} ig - ignore rules
63
64
  */
64
- copyTemplates(templatesDir: string, targetDir: string, ig: ignore.Ignore): void;
65
+ copyTemplates(templatesDir: string, targetDir: string, ig?: ignore.Ignore): void;
65
66
  }
66
67
 
67
68
  export { Copyer, Generator, type GeneratorOptions, type GeneratorResult, type TaskOptions, type TemplateFile, validRequiredString };
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@qlover/fe-scripts"),e=require("inquirer"),r=require("path"),o=require("ora"),i=require("fs"),n=require("ignore");function s(t,e,r,o){return new(r||(r=Promise))((function(i,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,c=[{type:"input",name:"name",message:"Project name",validate:t=>a(t,"Project name")},{type:"list",name:"templateName",message:"Template name",choices:["fe-react","pack-app"]}];class p{getIg(t){const e=r.join(t,".gitignore"),o=i.readFileSync(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return n().add(o)}copyTemplates(t,e,o){const n=i.readdirSync(t);for(const s of n){const n=r.join(t,s),a=r.join(e,s);if(o.ignores(s))continue;const c=r.dirname(a);i.existsSync(c)||i.mkdirSync(c,{recursive:!0}),i.statSync(n).isDirectory()?this.copyTemplates(n,a,o):i.copyFileSync(n,a)}}}exports.Copyer=p,exports.Generator=class{constructor(e){var r,n;this.prompts=[];const s=null===(r=e.options)||void 0===r?void 0:r.templatePath;if(!s)throw new Error("template path not exit");if(!i.existsSync(s))throw new Error("template path not exit");this.ora=o.oraPromise,this.context=new t.FeScriptContext(e),this.prompts=(null===(n=e.options)||void 0===n?void 0:n.prompts)||c}get logger(){return this.context.logger}steps(t){return s(this,void 0,void 0,(function*(){try{return yield e.prompt(t)}catch(t){throw this.logger.error(t),t}}))}getTemplateFiles(t){return s(this,void 0,void 0,(function*(){return console.log("jj paths",t),[]}))}action(t){return s(this,arguments,void 0,(function*({label:t,task:e}){let r=e();r instanceof Promise||(r=Promise.resolve(r));const o=t;return this.ora(r,o),r}))}create(t,e){return s(this,void 0,void 0,(function*(){const r=new p;r.copyTemplates(t,e,r.getIg(t))}))}generate(){return s(this,void 0,void 0,(function*(){const{templatePath:t}=this.context.options,e=yield this.steps(this.prompts);this.logger.info(e);const o=r.join(t,e.templateName);yield this.action({label:"Creating project",task:()=>this.create(o,e.name)})}))}},exports.validRequiredString=a;
1
+ "use strict";var t=require("@qlover/fe-scripts"),e=require("inquirer"),r=require("path"),o=require("ora"),i=require("fs"),n=require("ignore");function s(t,e,r,o){return new(r||(r=Promise))((function(i,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((o=o.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,c=[{type:"input",name:"name",message:"Project name",validate:t=>a(t,"Project name")},{type:"list",name:"templateName",message:"Template name",choices:["fe-react","pack-app"]}];class p{getIg(t){const e=r.join(t,p.IGNORE_FILE);if(!i.existsSync(e))return;const o=i.readFileSync(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return n().add(o)}copyTemplates(t,e,o){const n=i.readdirSync(t);for(const s of n){const n=r.join(t,s),a=r.join(e,s);if(o&&o.ignores(s))continue;const c=r.dirname(a);i.existsSync(c)||i.mkdirSync(c,{recursive:!0}),i.statSync(n).isDirectory()?this.copyTemplates(n,a,o):i.copyFileSync(n,a)}}}p.IGNORE_FILE=".gitignore.template";exports.Copyer=p,exports.Generator=class{constructor(e){var r,n;this.prompts=[];const s=null===(r=e.options)||void 0===r?void 0:r.templatePath;if(!s)throw new Error("template path not exit");if(!i.existsSync(s))throw new Error("template path not exit");this.ora=o.oraPromise,this.context=new t.FeScriptContext(e),this.prompts=(null===(n=e.options)||void 0===n?void 0:n.prompts)||c}get logger(){return this.context.logger}steps(t){return s(this,void 0,void 0,(function*(){try{return yield e.prompt(t)}catch(t){throw this.logger.error(t),t}}))}getTemplateFiles(t){return s(this,void 0,void 0,(function*(){return console.log("jj paths",t),[]}))}action(t){return s(this,arguments,void 0,(function*({label:t,task:e}){let r=e();r instanceof Promise||(r=Promise.resolve(r));const o=t;return this.ora(r,o),r}))}create(t,e){return s(this,void 0,void 0,(function*(){const r=new p;r.copyTemplates(t,e,r.getIg(t))}))}generate(){return s(this,void 0,void 0,(function*(){const{templatePath:t}=this.context.options,e=yield this.steps(this.prompts);this.logger.info(e);const o=r.join(t,e.templateName);yield this.action({label:"Creating project",task:()=>this.create(o,e.name)})}))}},exports.validRequiredString=a;
@@ -54,14 +54,15 @@ declare class Generator {
54
54
  declare const validRequiredString: (value: string, key: string) => string | true;
55
55
 
56
56
  declare class Copyer {
57
- getIg(targetDir: string): ignore.Ignore;
57
+ static IGNORE_FILE: string;
58
+ getIg(targetDir: string): ignore.Ignore | undefined;
58
59
  /**
59
60
  * copy templates recursively
60
61
  * @param {string} templatesDir - source directory
61
62
  * @param {string} targetDir - target directory
62
63
  * @param {ignore.Ignore} ig - ignore rules
63
64
  */
64
- copyTemplates(templatesDir: string, targetDir: string, ig: ignore.Ignore): void;
65
+ copyTemplates(templatesDir: string, targetDir: string, ig?: ignore.Ignore): void;
65
66
  }
66
67
 
67
68
  export { Copyer, Generator, type GeneratorOptions, type GeneratorResult, type TaskOptions, type TemplateFile, validRequiredString };
package/dist/es/index.js CHANGED
@@ -1 +1 @@
1
- import{FeScriptContext as t}from"@qlover/fe-scripts";import e from"inquirer";import{join as o,dirname as r}from"path";import{oraPromise as i}from"ora";import{readFileSync as n,readdirSync as s,existsSync as a,mkdirSync as p,statSync as c,copyFileSync as m}from"fs";import l from"ignore";function u(t,e,o,r){return new(o||(o=Promise))((function(i,n){function s(t){try{p(r.next(t))}catch(t){n(t)}}function a(t){try{p(r.throw(t))}catch(t){n(t)}}function p(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}p((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const h=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,f=[{type:"input",name:"name",message:"Project name",validate:t=>h(t,"Project name")},{type:"list",name:"templateName",message:"Template name",choices:["fe-react","pack-app"]}];class g{getIg(t){const e=o(t,".gitignore"),r=n(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return l().add(r)}copyTemplates(t,e,i){const n=s(t);for(const s of n){const n=o(t,s),l=o(e,s);if(i.ignores(s))continue;const u=r(l);a(u)||p(u,{recursive:!0}),c(n).isDirectory()?this.copyTemplates(n,l,i):m(n,l)}}}class d{constructor(e){var o,r;this.prompts=[];const n=null===(o=e.options)||void 0===o?void 0:o.templatePath;if(!n)throw new Error("template path not exit");if(!a(n))throw new Error("template path not exit");this.ora=i,this.context=new t(e),this.prompts=(null===(r=e.options)||void 0===r?void 0:r.prompts)||f}get logger(){return this.context.logger}steps(t){return u(this,void 0,void 0,(function*(){try{return yield e.prompt(t)}catch(t){throw this.logger.error(t),t}}))}getTemplateFiles(t){return u(this,void 0,void 0,(function*(){return console.log("jj paths",t),[]}))}action(t){return u(this,arguments,void 0,(function*({label:t,task:e}){let o=e();o instanceof Promise||(o=Promise.resolve(o));const r=t;return this.ora(o,r),o}))}create(t,e){return u(this,void 0,void 0,(function*(){const o=new g;o.copyTemplates(t,e,o.getIg(t))}))}generate(){return u(this,void 0,void 0,(function*(){const{templatePath:t}=this.context.options,e=yield this.steps(this.prompts);this.logger.info(e);const r=o(t,e.templateName);yield this.action({label:"Creating project",task:()=>this.create(r,e.name)})}))}}export{g as Copyer,d as Generator,h as validRequiredString};
1
+ import{FeScriptContext as t}from"@qlover/fe-scripts";import e from"inquirer";import{join as o,dirname as r}from"path";import{oraPromise as i}from"ora";import{existsSync as n,readFileSync as s,readdirSync as a,mkdirSync as p,statSync as c,copyFileSync as m}from"fs";import l from"ignore";function u(t,e,o,r){return new(o||(o=Promise))((function(i,n){function s(t){try{p(r.next(t))}catch(t){n(t)}}function a(t){try{p(r.throw(t))}catch(t){n(t)}}function p(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}p((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const h=(t,e)=>"string"==typeof t&&""!==t.trim()||`${e} is required`,f=[{type:"input",name:"name",message:"Project name",validate:t=>h(t,"Project name")},{type:"list",name:"templateName",message:"Template name",choices:["fe-react","pack-app"]}];class g{getIg(t){const e=o(t,g.IGNORE_FILE);if(!n(e))return;const r=s(e,"utf8").split("\n").map((t=>t.trim())).filter((t=>t&&!t.startsWith("#")));return l().add(r)}copyTemplates(t,e,i){const s=a(t);for(const a of s){const s=o(t,a),l=o(e,a);if(i&&i.ignores(a))continue;const u=r(l);n(u)||p(u,{recursive:!0}),c(s).isDirectory()?this.copyTemplates(s,l,i):m(s,l)}}}g.IGNORE_FILE=".gitignore.template";class d{constructor(e){var o,r;this.prompts=[];const s=null===(o=e.options)||void 0===o?void 0:o.templatePath;if(!s)throw new Error("template path not exit");if(!n(s))throw new Error("template path not exit");this.ora=i,this.context=new t(e),this.prompts=(null===(r=e.options)||void 0===r?void 0:r.prompts)||f}get logger(){return this.context.logger}steps(t){return u(this,void 0,void 0,(function*(){try{return yield e.prompt(t)}catch(t){throw this.logger.error(t),t}}))}getTemplateFiles(t){return u(this,void 0,void 0,(function*(){return console.log("jj paths",t),[]}))}action(t){return u(this,arguments,void 0,(function*({label:t,task:e}){let o=e();o instanceof Promise||(o=Promise.resolve(o));const r=t;return this.ora(o,r),o}))}create(t,e){return u(this,void 0,void 0,(function*(){const o=new g;o.copyTemplates(t,e,o.getIg(t))}))}generate(){return u(this,void 0,void 0,(function*(){const{templatePath:t}=this.context.options,e=yield this.steps(this.prompts);this.logger.info(e);const r=o(t,e.templateName);yield this.action({label:"Creating project",task:()=>this.create(r,e.name)})}))}}export{g as Copyer,d as Generator,h as validRequiredString};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlover/create-app",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/es/index.js",
@@ -0,0 +1,32 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+ # typescript
15
+ *.tsbuildinfo
16
+
17
+ # Editor directories and files
18
+ .vscode/*
19
+ !.vscode/extensions.json
20
+ .idea
21
+ .DS_Store
22
+ *.suo
23
+ *.ntvs*
24
+ *.njsproj
25
+ *.sln
26
+ *.sw?
27
+
28
+ # lock
29
+ yarn.lock
30
+ pnpm-lock.yaml
31
+ pnpm-lock.yml
32
+ package-lock.json
@@ -0,0 +1,50 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # next.js
12
+ /.next/
13
+ /out/
14
+
15
+ # production
16
+ /build
17
+
18
+ # misc
19
+ .DS_Store
20
+ *.pem
21
+
22
+ # debug
23
+ npm-debug.log*
24
+ yarn-debug.log*
25
+ yarn-error.log*
26
+ .pnpm-debug.log*
27
+
28
+ # local env files
29
+ .env*.local
30
+
31
+ # vercel
32
+ .vercel
33
+
34
+ # typescript
35
+ *.tsbuildinfo
36
+ next-env.d.ts
37
+
38
+ /package-lock.json
39
+ /yarn.lock
40
+ .husky
41
+ /pnpm-lock.yaml
42
+ public/robots.txt
43
+ public/sitemap*.xml
44
+ dist
45
+ .eslintcache
46
+ .npmrc
47
+ .secrets
48
+
49
+ # local output dir
50
+ *.output/