@pavlos-samaras/react-cli 2.0.2 → 2.1.0
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/commands/generate/utils/generateComponent.d.ts.map +1 -1
- package/dist/commands/generate/utils/generateComponent.js +7 -6
- package/dist/commands/generate/utils/generateComponent.js.map +1 -1
- package/dist/commands/generate/utils/generateHook.d.ts.map +1 -1
- package/dist/commands/generate/utils/generateHook.js +3 -2
- package/dist/commands/generate/utils/generateHook.js.map +1 -1
- package/dist/commands/generate/utils/runGenerateComponent.js +1 -1
- package/dist/commands/generate/utils/runGenerateComponent.js.map +1 -1
- package/dist/commands/generate/utils/runGenerateHook.js +1 -1
- package/dist/commands/generate/utils/runGenerateHook.js.map +1 -1
- package/dist/commands/new/new.constants.d.ts +2 -0
- package/dist/commands/new/new.constants.d.ts.map +1 -1
- package/dist/commands/new/new.constants.js +2 -0
- package/dist/commands/new/new.constants.js.map +1 -1
- package/dist/commands/new/new.d.ts.map +1 -1
- package/dist/commands/new/new.js +16 -27
- package/dist/commands/new/new.js.map +1 -1
- package/dist/commands/new/new.types.d.ts +7 -0
- package/dist/commands/new/new.types.d.ts.map +1 -0
- package/dist/commands/new/new.types.js +2 -0
- package/dist/commands/new/new.types.js.map +1 -0
- package/dist/commands/new/utils/general.d.ts +3 -0
- package/dist/commands/new/utils/general.d.ts.map +1 -0
- package/dist/commands/new/utils/general.js +6 -0
- package/dist/commands/new/utils/general.js.map +1 -0
- package/dist/commands/new/utils/runCommand.d.ts +2 -0
- package/dist/commands/new/utils/runCommand.d.ts.map +1 -0
- package/dist/commands/new/utils/runCommand.js +7 -0
- package/dist/commands/new/utils/runCommand.js.map +1 -0
- package/dist/commands/new/utils/runCreateVite.d.ts +2 -0
- package/dist/commands/new/utils/runCreateVite.d.ts.map +1 -0
- package/dist/commands/new/utils/runCreateVite.js +32 -0
- package/dist/commands/new/utils/runCreateVite.js.map +1 -0
- package/dist/commands/new/utils/runCustomTemplate.d.ts +3 -0
- package/dist/commands/new/utils/runCustomTemplate.d.ts.map +1 -0
- package/dist/commands/new/utils/runCustomTemplate.js +25 -0
- package/dist/commands/new/utils/runCustomTemplate.js.map +1 -0
- package/dist/utils/general.d.ts +4 -0
- package/dist/utils/general.d.ts.map +1 -0
- package/dist/utils/general.js +3 -0
- package/dist/utils/general.js.map +1 -0
- package/package.json +3 -2
- package/templates/component.tpl +9 -0
- package/templates/hook.tpl +3 -0
- package/templates/react/README.md +12 -0
- package/templates/react/eslint.config.js +29 -0
- package/templates/react/index.html +13 -0
- package/templates/react/jsconfig.json +13 -0
- package/templates/react/package.json +30 -0
- package/templates/react/public/favicon.svg +1 -0
- package/templates/react/src/app/App.jsx +12 -0
- package/templates/react/src/app/providers.jsx +13 -0
- package/templates/react/src/app/routes.jsx +19 -0
- package/templates/react/src/config/queryClient.config.js +12 -0
- package/templates/react/src/lib/queryClient.jsx +6 -0
- package/templates/react/src/main.jsx +13 -0
- package/templates/react/src/pages/home/Home.jsx +11 -0
- package/templates/react/src/pages/home/Home.module.scss +0 -0
- package/templates/react/vite.config.js +18 -0
- package/templates/react-ts/README.md +75 -0
- package/templates/react-ts/eslint.config.js +22 -0
- package/templates/react-ts/index.html +13 -0
- package/templates/react-ts/package-lock.json +3221 -0
- package/templates/react-ts/package.json +33 -0
- package/templates/react-ts/public/favicon.svg +1 -0
- package/templates/react-ts/src/app/App.tsx +12 -0
- package/templates/react-ts/src/app/providers.tsx +16 -0
- package/templates/react-ts/src/app/routes.tsx +19 -0
- package/templates/react-ts/src/config/queryClient.config.ts +14 -0
- package/templates/react-ts/src/lib/queryClient.tsx +6 -0
- package/templates/react-ts/src/main.tsx +13 -0
- package/templates/react-ts/src/pages/home/Home.module.scss +0 -0
- package/templates/react-ts/src/pages/home/Home.tsx +11 -0
- package/templates/react-ts/tsconfig.app.json +29 -0
- package/templates/react-ts/tsconfig.json +7 -0
- package/templates/react-ts/tsconfig.node.json +23 -0
- package/templates/react-ts/vite.config.ts +18 -0
- package/templates/stylesheet.tpl +3 -0
- package/dist/templates/component.d.ts +0 -3
- package/dist/templates/component.d.ts.map +0 -1
- package/dist/templates/component.js +0 -11
- package/dist/templates/component.js.map +0 -1
- package/dist/templates/hook.d.ts +0 -3
- package/dist/templates/hook.d.ts.map +0 -1
- package/dist/templates/hook.js +0 -5
- package/dist/templates/hook.js.map +0 -1
- package/dist/templates/stylesheet.d.ts +0 -3
- package/dist/templates/stylesheet.d.ts.map +0 -1
- package/dist/templates/stylesheet.js +0 -7
- package/dist/templates/stylesheet.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponent.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateComponent.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateComponent.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAiB/D,eAAO,MAAM,iBAAiB,WACpB,MAAM,QACR,MAAM,WACH,OAAO,KACf,OAAO,CAAC,SAAS,CA+BnB,CAAC"}
|
|
@@ -2,9 +2,7 @@ import path from "path";
|
|
|
2
2
|
import prompts from "prompts";
|
|
3
3
|
import { loadConfig } from "../../../utils/loadConfig.js";
|
|
4
4
|
import { isTypescriptUsed } from "../../../utils/validators.js";
|
|
5
|
-
import
|
|
6
|
-
import buildStylesheetTemplate from "../../../templates/stylesheet.js";
|
|
7
|
-
import buildHookTemplate from "../../../templates/hook.js";
|
|
5
|
+
import { getTemplate } from "../../../utils/general.js";
|
|
8
6
|
// Utilities
|
|
9
7
|
const askForStyle = async () => {
|
|
10
8
|
const answer = await prompts({
|
|
@@ -27,15 +25,18 @@ export const generateComponent = async (folder, name, options) => {
|
|
|
27
25
|
return {
|
|
28
26
|
JSX: {
|
|
29
27
|
path: path.join(folder, `${name}.${langExt}x`),
|
|
30
|
-
content:
|
|
28
|
+
content: getTemplate("component")
|
|
29
|
+
.replace(/__NAME__/g, name)
|
|
30
|
+
.replace(/__CLASSNAME__/, name.toLowerCase())
|
|
31
|
+
.replace(/.scss/g, `.${stylesheetExt}`),
|
|
31
32
|
},
|
|
32
33
|
stylesheet: {
|
|
33
34
|
path: path.join(folder, `${name}.module.${stylesheetExt}`),
|
|
34
|
-
content:
|
|
35
|
+
content: getTemplate("stylesheet").replace(/__CLASSNAME__/, name.toLowerCase()),
|
|
35
36
|
},
|
|
36
37
|
hook: {
|
|
37
38
|
path: path.join(folder, `use${name}.${langExt}`),
|
|
38
|
-
content:
|
|
39
|
+
content: getTemplate("hook").replace(/__NAME__/g, name),
|
|
39
40
|
},
|
|
40
41
|
test: {
|
|
41
42
|
path: path.join(folder, `${name}.test.${langExt}`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponent.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"generateComponent.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,YAAY;AACZ,MAAM,WAAW,GAAG,KAAK,IAAqB,EAAE;IAC9C,MAAM,MAAM,GAAG,MAAM,OAAO,CA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YAAY,CAAC,CAAC,OAAO,CACxC,eAAe,EACf,IAAI,CAAC,WAAW,EAAE,CACnB;SACF;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAChD,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;SACxD;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,SAAS,OAAO,EAAE,CAAC;YAClD,OAAO,EAAE,EAAE;SACZ;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHook.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateHook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"generateHook.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateHook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,eAAO,MAAM,YAAY,WACf,MAAM,QACR,MAAM,WACH,OAAO;;;EAUjB,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
2
3
|
import { loadConfig } from "../../../utils/loadConfig.js";
|
|
3
4
|
import { isTypescriptUsed } from "../../../utils/validators.js";
|
|
4
|
-
import
|
|
5
|
+
import { getTemplate } from "../../../utils/general.js";
|
|
5
6
|
export const generateHook = async (folder, name, options) => {
|
|
6
7
|
const config = loadConfig() ?? {};
|
|
7
8
|
const useTs = options.ts ?? config.typescript ?? isTypescriptUsed();
|
|
8
9
|
const langExt = useTs ? "ts" : "js";
|
|
9
10
|
return {
|
|
10
11
|
path: path.join(folder, `${name}.${langExt}`),
|
|
11
|
-
content:
|
|
12
|
+
content: getTemplate("hook").replace(/__NAME__/g, name),
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
//# sourceMappingURL=generateHook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHook.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateHook.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"generateHook.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/generateHook.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,MAAc,EACd,IAAY,EACZ,OAAgB,EAChB,EAAE;IACF,MAAM,MAAM,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,IAAI,gBAAgB,EAAE,CAAC;IACpE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;QAC7C,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;KACxD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ export const runGenerateComponent = async (rootDir, name, options) => {
|
|
|
10
10
|
process.exitCode = 1;
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
const folder = createDir(`${rootDir}/${options.dir ?? "
|
|
13
|
+
const folder = createDir(`${rootDir}/${options.dir ?? "components"}/${name}`);
|
|
14
14
|
if (!folder) {
|
|
15
15
|
warning(`Folder ${name} already exists!`);
|
|
16
16
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runGenerateComponent.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/runGenerateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,OAAe,EACf,IAAY,EACZ,OAAgB,EAChB,EAAE;IACF,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"runGenerateComponent.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/runGenerateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAA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
process.exitCode = 1;
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
const folder = createDir(`${rootDir}/${options.dir ?? "
|
|
13
|
+
const folder = createDir(`${rootDir}/${options.dir ?? "hooks"}/${name}`);
|
|
14
14
|
if (!folder) {
|
|
15
15
|
warning(`Folder ${name} already exists!`);
|
|
16
16
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runGenerateHook.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/runGenerateHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,OAAe,EACf,IAAY,EACZ,OAAgB,EAChB,EAAE;IACF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;QACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"runGenerateHook.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/runGenerateHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,OAAe,EACf,IAAY,EACZ,OAAgB,EAChB,EAAE;IACF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;QACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;IACzE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,UAAU,IAAI,kBAAkB,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG,IAAI,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.constants.d.ts","sourceRoot":"","sources":["../../../src/commands/new/new.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"new.constants.d.ts","sourceRoot":"","sources":["../../../src/commands/new/new.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AACzD,eAAO,MAAM,SAAS,YAAI,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,CAAU,CAAC;AACrF,eAAO,MAAM,gBAAgB,YAAI,WAAW,EAAE,WAAW,CAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.constants.js","sourceRoot":"","sources":["../../../src/commands/new/new.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"new.constants.js","sourceRoot":"","sources":["../../../src/commands/new/new.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,CAAU,CAAC;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,WAAW,CAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/commands/new/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/commands/new/new.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,eAAO,MAAM,kBAAkB,YAAa,OAAO,SAqClD,CAAC"}
|
package/dist/commands/new/new.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
3
|
import { error, info, warning } from "../../utils/console.js";
|
|
5
|
-
import { VALID_REACT_NAME } from "./new.constants.js";
|
|
4
|
+
import { CUSTOM_TEMPLATES, TEMPLATES, VALID_REACT_NAME, } from "./new.constants.js";
|
|
5
|
+
import { runCustomTemplate } from "./utils/runCustomTemplate.js";
|
|
6
|
+
import { runCreateVite } from "./utils/runCreateVite.js";
|
|
7
|
+
import { isCustomTemplate, isInvalidTemplate } from "./utils/general.js";
|
|
6
8
|
export const registerNewCommand = (program) => {
|
|
7
9
|
program
|
|
8
10
|
.command("new <name>")
|
|
9
11
|
.description("Create a new React project with Vite")
|
|
10
|
-
.
|
|
12
|
+
.option("-t, --template <template>", "apply a react Vite template. Use (custom-ts or custom-js) for a custom src layout")
|
|
13
|
+
.action((name, options) => {
|
|
11
14
|
if (!VALID_REACT_NAME.test(name)) {
|
|
12
15
|
error(`Invalid name ${name}`);
|
|
13
16
|
process.exitCode = 1;
|
|
14
17
|
return;
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
if (isInvalidTemplate(options.template)) {
|
|
20
|
+
const templates = [...TEMPLATES, ...CUSTOM_TEMPLATES].join(", ");
|
|
21
|
+
error(`Invalid template ${options.template}`);
|
|
22
|
+
info(`You can choose between: ${templates}`);
|
|
19
23
|
process.exitCode = 1;
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
const vitePassed = result.status === 0;
|
|
27
|
-
if (!vitePassed && !fs.existsSync(target)) {
|
|
28
|
-
error("Vite failed before creating the project.");
|
|
26
|
+
const target = path.join(process.cwd(), name);
|
|
27
|
+
if (fs.existsSync(target)) {
|
|
28
|
+
warning(`Folder ${name} already exists!`);
|
|
29
29
|
process.exitCode = 1;
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
runCreateVite(name, target, options.template);
|
|
32
33
|
fs.writeFileSync(path.join(target, "ct.config.json"), "{}");
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
const retry = spawnSync("npm install --legacy-peer-deps", {
|
|
36
|
-
cwd: target,
|
|
37
|
-
stdio: "inherit",
|
|
38
|
-
shell: true,
|
|
39
|
-
});
|
|
40
|
-
if (retry.status !== 0) {
|
|
41
|
-
error("Install failed again. Finish it manually:");
|
|
42
|
-
info(`cd ${name}\nnpm install --legacy-peer-deps`);
|
|
43
|
-
process.exitCode = 1;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
34
|
+
if (isCustomTemplate(options.template)) {
|
|
35
|
+
runCustomTemplate(target, options);
|
|
46
36
|
}
|
|
47
|
-
info(`\nDone! Next steps:\n\ncd ${name}\nnpm run dev`);
|
|
48
37
|
});
|
|
49
38
|
};
|
|
50
39
|
//# sourceMappingURL=new.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/new/new.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/commands/new/new.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACrD,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,sCAAsC,CAAC;SACnD,MAAM,CACL,2BAA2B,EAC3B,mFAAmF,CACpF;SACA,MAAM,CAAC,CAAC,IAAY,EAAE,OAAgB,EAAE,EAAE;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./new.constants.js";
|
|
2
|
+
export type Template = (typeof TEMPLATES)[number];
|
|
3
|
+
export type CustomTemplate = (typeof CUSTOM_TEMPLATES)[number];
|
|
4
|
+
export interface Options {
|
|
5
|
+
template?: Template | CustomTemplate;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=new.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.types.d.ts","sourceRoot":"","sources":["../../../src/commands/new/new.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,QAAQ,GAAG,cAAc,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.types.js","sourceRoot":"","sources":["../../../src/commands/new/new.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../src/commands/new/utils/general.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,cAAe,MAAM,6BAGR,CAAC;AAE5C,eAAO,MAAM,gBAAgB,cAAe,MAAM,6BACiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CUSTOM_TEMPLATES, TEMPLATES } from "../new.constants.js";
|
|
2
|
+
export const isInvalidTemplate = (template) => template &&
|
|
3
|
+
!CUSTOM_TEMPLATES.includes(template) &&
|
|
4
|
+
!TEMPLATES.includes(template);
|
|
5
|
+
export const isCustomTemplate = (template) => template && CUSTOM_TEMPLATES.includes(template);
|
|
6
|
+
//# sourceMappingURL=general.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../../src/commands/new/utils/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGlE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAiB,EAAE,EAAE,CACrD,QAAQ;IACR,CAAC,gBAAgB,CAAC,QAAQ,CAAC,QAA0B,CAAC;IACtD,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAoB,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAiB,EAAE,EAAE,CACpD,QAAQ,IAAI,gBAAgB,CAAC,QAAQ,CAAC,QAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/new/utils/runCommand.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,WAAW,MAAM,mEAKvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../../../src/commands/new/utils/runCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,MAAe,EAAE,EAAE,CAC7D,SAAS,CAAC,OAAO,EAAE;IACjB,GAAG,CAAC,MAAM,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAC9B,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCreateVite.d.ts","sourceRoot":"","sources":["../../../../src/commands/new/utils/runCreateVite.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,aAAa,SAClB,MAAM,UACJ,MAAM,aACH,MAAM,SAmBlB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { warning, error, info } from "../../../utils/console.js";
|
|
3
|
+
import { TEMPLATES } from "../new.constants.js";
|
|
4
|
+
import { runCommand } from "./runCommand.js";
|
|
5
|
+
// Utility
|
|
6
|
+
const retryInstallDependencies = (name, target) => {
|
|
7
|
+
warning("Install failed (dependency conflict). Retrying with --legacy-peer-deps...");
|
|
8
|
+
const retry = runCommand("npm install --legacy-peer-deps", target);
|
|
9
|
+
if (retry.status !== 0) {
|
|
10
|
+
error("Install failed again. Finish it manually:");
|
|
11
|
+
info(`cd ${name}\nnpm install --legacy-peer-deps`);
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const runCreateVite = (name, target, template) => {
|
|
17
|
+
const createViteCommand = template
|
|
18
|
+
? TEMPLATES.includes(template)
|
|
19
|
+
? `npm create vite@latest ${name} -- --template ${template} --no-interactive`
|
|
20
|
+
: `npm create vite@latest ${name} -- --template ${template.endsWith("-ts") ? "react-ts" : "react"} --no-interactive`
|
|
21
|
+
: `npm create vite@latest ${name}`;
|
|
22
|
+
const result = runCommand(createViteCommand);
|
|
23
|
+
const vitePassed = result.status === 0;
|
|
24
|
+
if (!vitePassed && !fs.existsSync(target)) {
|
|
25
|
+
error("Vite failed before creating the project.");
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!vitePassed)
|
|
30
|
+
retryInstallDependencies(name, target);
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=runCreateVite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCreateVite.js","sourceRoot":"","sources":["../../../../src/commands/new/utils/runCreateVite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAA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OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,IAAI,CAAC,UAAU;QAAE,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCustomTemplate.d.ts","sourceRoot":"","sources":["../../../../src/commands/new/utils/runCustomTemplate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,OAAO,SAkBjE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
// Utility
|
|
4
|
+
const removeDefaultFiles = (target, files) => {
|
|
5
|
+
for (const file in files)
|
|
6
|
+
fs.rmSync(path.join(target, file), { force: true });
|
|
7
|
+
fs.rmSync(path.join(target, "src/assets"), { recursive: true, force: true });
|
|
8
|
+
};
|
|
9
|
+
export const runCustomTemplate = (target, options) => {
|
|
10
|
+
if (!options.template)
|
|
11
|
+
return;
|
|
12
|
+
const isTs = options.template.endsWith("-ts");
|
|
13
|
+
const variant = isTs ? "react-ts" : "react";
|
|
14
|
+
const overlay = new URL(`../../../../templates/${variant}`, import.meta.url);
|
|
15
|
+
const ext = isTs ? "tsx" : "jsx";
|
|
16
|
+
const filesToRemove = [
|
|
17
|
+
`src/App.${ext}`,
|
|
18
|
+
"src/App.css",
|
|
19
|
+
"src/index.css",
|
|
20
|
+
".oxlintrc.json",
|
|
21
|
+
];
|
|
22
|
+
removeDefaultFiles(target, filesToRemove);
|
|
23
|
+
fs.cpSync(overlay, target, { recursive: true });
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=runCustomTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCustomTemplate.js","sourceRoot":"","sources":["../../../../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EAAE,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/utils/general.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,CAAC;AAE7D,eAAO,MAAM,WAAW,aAAc,QAAQ,WAI3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../src/utils/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAkB,EAAE,EAAE,CAChD,EAAE,CAAC,YAAY,CACb,IAAI,GAAG,CAAC,mBAAmB,QAAQ,MAAM,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAC3D,OAAO,CACR,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pavlos-samaras/react-cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "sammern-stack",
|
|
5
5
|
"description": "A CLI to generate React code",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"typescript": "^7.0.2"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"templates"
|
|
36
37
|
]
|
|
37
38
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# React + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
6
|
+
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
globalIgnores(['dist']),
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.{js,jsx}'],
|
|
11
|
+
extends: [
|
|
12
|
+
js.configs.recommended,
|
|
13
|
+
reactHooks.configs.flat.recommended,
|
|
14
|
+
reactRefresh.configs.vite,
|
|
15
|
+
],
|
|
16
|
+
languageOptions: {
|
|
17
|
+
ecmaVersion: 2020,
|
|
18
|
+
globals: globals.browser,
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaVersion: 'latest',
|
|
21
|
+
ecmaFeatures: { jsx: true },
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>my-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@tanstack/react-query": "^5.106.1",
|
|
14
|
+
"react": "^19.3.1",
|
|
15
|
+
"react-dom": "^19.3.1",
|
|
16
|
+
"react-router": "^8.5.1",
|
|
17
|
+
"sass": "^1.107.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^10.0.1",
|
|
21
|
+
"@types/react": "^19.3.0",
|
|
22
|
+
"@types/react-dom": "^19.3.0",
|
|
23
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
24
|
+
"eslint": "^10.14.0",
|
|
25
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
26
|
+
"eslint-plugin-react-refresh": "^0.5.7",
|
|
27
|
+
"globals": "^17.13.0",
|
|
28
|
+
"vite": "^8.3.6"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="46" fill="none" viewBox="0 0 48 46"><path fill="#863bff" d="M25.946 44.938c-.664.845-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.287c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.497 0-3.578-1.842-3.578H1.237c-.92 0-1.456-1.04-.92-1.788L10.013.474c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.579 1.842 3.579h11.377c.943 0 1.473 1.088.89 1.83L25.947 44.94z" style="fill:#863bff;fill:color(display-p3 .5252 .23 1);fill-opacity:1"/><mask id="a" width="48" height="46" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M25.842 44.938c-.664.844-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.183c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.498 0-3.579-1.842-3.579H1.133c-.92 0-1.456-1.04-.92-1.787L9.91.473c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.578 1.842 3.578h11.377c.943 0 1.473 1.088.89 1.832L25.843 44.94z" style="fill:#000;fill-opacity:1"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#ede6ff" rx="5.508" ry="14.704" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -4.47 31.516)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#ede6ff" rx="10.399" ry="29.851" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -39.328 7.883)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#7e14ff" rx="5.508" ry="30.487" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -25.913 -14.639)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -32.644 -3.334)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -34.34 30.47)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#ede6ff" rx="14.072" ry="22.078" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="rotate(93.35 24.506 48.493)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx=".387" cy="8.972" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(39.51 .387 8.972)"/></g><g filter="url(#k)"><ellipse cx="47.523" cy="-6.092" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 47.523 -6.092)"/></g><g filter="url(#l)"><ellipse cx="41.412" cy="6.333" fill="#47bfff" rx="5.971" ry="9.665" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 41.412 6.333)"/></g><g filter="url(#m)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#n)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#o)"><ellipse cx="35.651" cy="29.907" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 35.651 29.907)"/></g><g filter="url(#p)"><ellipse cx="38.418" cy="32.4" fill="#47bfff" rx="5.971" ry="15.297" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 38.418 32.4)"/></g></g><defs><filter id="b" width="60.045" height="41.654" x="-19.77" y="16.149" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-54.613" y="-7.533" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-49.64" y="2.03" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-45.045" y="20.029" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-43.513" y="21.178" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="15.756" y="-17.901" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="23.548" y="2.284" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="23.548" y="2.284" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-27.636" y="-22.853" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="20.116" y="-38.415" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="24.641" y="-11.323" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-29.286" y="6.009" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-29.286" y="6.009" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="8.244" y="-2.416" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="18.713" y="10.588" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="4.596"/></filter></defs></svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BrowserRouter } from "react-router";
|
|
2
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
+
import queryClient from "@/lib/queryClient";
|
|
4
|
+
|
|
5
|
+
const Providers = ({ children }) => {
|
|
6
|
+
return (
|
|
7
|
+
<QueryClientProvider client={queryClient}>
|
|
8
|
+
<BrowserRouter>{children}</BrowserRouter>
|
|
9
|
+
</QueryClientProvider>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Providers;
|