@qlover/create-app 0.1.3 → 0.1.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 +2 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es/index.js +1 -1
- package/package.json +4 -2
- package/templates/node-lib/package.json +2 -1
- package/templates/node-lib/rollup.config.js +3 -2
- package/templates/react-app/package.json +1 -0
- package/templates/react-app/vite.config.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [0.1.4](https://github.com/qlover/fe-base/compare/create-app-v0.1.3...create-app-v0.1.4) (2025-01-20)
|
|
4
|
+
|
|
3
5
|
## [0.1.3](https://github.com/qlover/fe-base/compare/create-app-v0.1.2...create-app-v0.1.3) (2025-01-17)
|
|
4
6
|
|
|
5
7
|
## [0.1.2](https://github.com/qlover/fe-base/compare/create-app-v0.1.1...create-app-v0.1.2) (2025-01-17)
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@qlover/
|
|
1
|
+
"use strict";var t=require("@qlover/scripts-context"),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.d.ts
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FeScriptContext as t}from"@qlover/
|
|
1
|
+
import{FeScriptContext as t}from"@qlover/scripts-context";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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlover/create-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/es/index.js",
|
|
@@ -48,8 +48,10 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@qlover/scripts-context": "latest"
|
|
53
|
+
},
|
|
51
54
|
"dependencies": {
|
|
52
|
-
"@qlover/fe-scripts": "latest",
|
|
53
55
|
"@qlover/fe-utils": "latest",
|
|
54
56
|
"ignore": "^7.0.3",
|
|
55
57
|
"inquirer": "^12.3.2",
|
|
@@ -6,11 +6,12 @@ import dts from 'rollup-plugin-dts';
|
|
|
6
6
|
import typescript from 'rollup-plugin-typescript2';
|
|
7
7
|
import { builtinModules } from 'module';
|
|
8
8
|
import { readFileSync, rmSync } from 'fs';
|
|
9
|
+
import { Env } from '@qlover/env-loader';
|
|
9
10
|
|
|
10
11
|
const pkg = JSON.parse(readFileSync('./package.json'), 'utf-8');
|
|
11
12
|
const tsConfig = JSON.parse(readFileSync('./tsconfig.json'), 'utf-8');
|
|
12
|
-
|
|
13
|
-
const isProduction =
|
|
13
|
+
const env = Env.searchEnv({ logger: console });
|
|
14
|
+
const isProduction = env.get('NODE_ENV') === 'production';
|
|
14
15
|
const buildDir = tsConfig.compilerOptions.outDir;
|
|
15
16
|
|
|
16
17
|
const treeshake = {
|
|
@@ -4,9 +4,9 @@ import alias from '@rollup/plugin-alias';
|
|
|
4
4
|
import react from '@vitejs/plugin-react';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import tsappconfig from './tsconfig.app.json';
|
|
7
|
-
import {
|
|
7
|
+
import { Env } from '@qlover/env-loader';
|
|
8
8
|
|
|
9
|
-
searchEnv(
|
|
9
|
+
Env.searchEnv();
|
|
10
10
|
|
|
11
11
|
const tsAppPaths = tsappconfig.compilerOptions.paths || {};
|
|
12
12
|
|