@design-edito/cli 0.0.57 → 0.0.58

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.
@@ -1 +1 @@
1
- 0.0.57
1
+ 0.0.58
@@ -3,27 +3,38 @@
3
3
  "version": "0.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
- "build:src": "npx esbuild src/index.tsx --bundle --minify --outfile=dist/index.js --platform=browser --target=esnext --jsx-factory=React.createElement --jsx-fragment=React.Fragment",
8
- "watch:src": "npm run build:src -- --watch",
8
+ "build:scripts": "npx tsc -p scripts/tsconfig.json",
9
+ "build:src": "npm run build:scripts && node .scripts/build/index.js",
10
+ "build:src:preact": "PREACT=true npm run build:src",
11
+ "watch:src": "WATCH=true npm run build:src",
12
+ "watch:src:preact": "PREACT=true npm run watch:src",
9
13
  "make:dist": "mkdir -p dist",
10
14
  "make:pages": "mkdir -p pages",
11
15
  "serve:dist": "npm run make:dist && npx http-server dist --port ${PORT} --cors -c-1",
12
16
  "serve:pages": "npm run make:pages && npx http-server pages --port ${PORT} --cors -c-1",
13
- "start": "npx concurrently -n 'watch:src ,serve:dist ,serve:pages' 'npm run watch:src' 'PORT=${PORT_DIST:-3001} npm run serve:dist' 'PORT=${PORT_DIST:-3000} npm run serve:pages'"
17
+ "start": "npx concurrently -n 'watch:src,serve:dist ,serve:pages' 'npm run watch:src' 'PORT=${PORT_DIST:-3001} npm run serve:dist' 'PORT=${PORT_DIST:-3000} npm run serve:pages'",
18
+ "start:preact": "PREACT=true npm start"
14
19
  },
15
20
  "author": "",
16
21
  "license": "ISC",
17
22
  "devDependencies": {
18
23
  "@types/node": "^20.11.30",
19
24
  "@types/react": "^18.2.72",
25
+ "@types/react-dom": "^18.2.22",
20
26
  "concurrently": "^8.2.2",
21
- "esbuild": "^0.20.2",
22
27
  "http-server": "^14.1.1",
23
- "typescript": "^5.4.3"
28
+ "typescript": "^5.4.3",
29
+ "esbuild": "^0.20.2",
30
+ "esbuild-plugin-inline-image": "^0.0.9",
31
+ "esbuild-sass-plugin": "^3.2.0",
32
+ "postcss": "^8.4.38",
33
+ "postcss-modules": "^6.0.0",
34
+ "sass": "^1.74.1"
24
35
  },
25
36
  "dependencies": {
26
- "@types/react-dom": "^18.2.22",
37
+ "preact": "^10.20.1",
27
38
  "react": "^18.2.0",
28
39
  "react-dom": "^18.2.0"
29
40
  }
@@ -11,6 +11,7 @@
11
11
  <link rel="icon" type="image/png" sizes="16x16" href="./icons/favicon-16x16.png">
12
12
  <link rel="manifest" href="./icons/site.webmanifest">
13
13
  <script type="module" src="http://localhost:3001/index.js"></script>
14
+ <link rel="stylesheet" href="http://localhost:3001/index.css">
14
15
  </head>
15
16
  <body>
16
17
  <div class="root"></div>
@@ -0,0 +1,44 @@
1
+ import esbuild, { BuildOptions } from 'esbuild'
2
+ import path from 'node:path'
3
+ import { sassPlugin, postcssModules } from 'esbuild-sass-plugin'
4
+ import inlineImageModule from 'esbuild-plugin-inline-image'
5
+
6
+ const PREACT = process.env.PREACT === 'true'
7
+ const WATCH = process.env.WATCH === 'true'
8
+
9
+ console.log(`scripts/build/index.ts PREACT=${PREACT} WATCH=${WATCH}`)
10
+
11
+ const options: BuildOptions = {
12
+ format: 'esm',
13
+ entryPoints: [path.join(process.cwd(), 'src/index.tsx')],
14
+ bundle: true,
15
+ outfile: path.join(process.cwd(), 'dist/index.js'),
16
+ minify: true,
17
+ platform: 'browser',
18
+ sourcemap: true,
19
+ target: ['esnext'],
20
+ tsconfig: path.join(process.cwd(), 'src/tsconfig.json'),
21
+ logLevel: 'info',
22
+ jsxFactory: PREACT ? 'h' : 'React.createElement',
23
+ jsxFragment: PREACT ? 'FRAGMENT' : 'React.Fragment',
24
+ plugins: [
25
+ inlineImageModule({ limit: -1 }),
26
+ sassPlugin({ filter: /\.module\.scss$/, type: 'css', transform: postcssModules({}) }),
27
+ sassPlugin({ filter: /.scss$/, type: 'css' })
28
+ ],
29
+ alias: PREACT ? {
30
+ 'react': 'preact/compat',
31
+ 'react-dom/test-utils': 'preact/test-utils',
32
+ 'react-dom': 'preact/compat',
33
+ 'react/jsx-runtime': 'preact/jsx-runtime'
34
+ } : {}
35
+ }
36
+
37
+ if (WATCH) {
38
+ const ctx = await esbuild.context(options)
39
+ await ctx.watch()
40
+ console.log('watching...')
41
+ } else {
42
+ await esbuild.build(options)
43
+ console.log('built.')
44
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "lib": ["ESNext"],
5
+ "module": "ESNext",
6
+ "target": "ESNext",
7
+ "baseUrl": ".",
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "outDir": "../.scripts",
11
+ "declaration": true,
12
+ "moduleResolution": "Node",
13
+ "rootDir": ".",
14
+ "noUncheckedIndexedAccess": true,
15
+ },
16
+ "include": ["**/*"],
17
+ "exclude": [
18
+ "../node_modules",
19
+ "../.scripts"
20
+ ]
21
+ }
@@ -1,3 +1,7 @@
1
+ import styles from './style.module.scss'
2
+
1
3
  export default function App () {
2
- return <div>App.</div>
4
+ return <div className={styles['app']}>
5
+ App.
6
+ </div>
3
7
  }
@@ -0,0 +1,3 @@
1
+ .app {
2
+ display: block;
3
+ }
@@ -0,0 +1,9 @@
1
+ declare module '*.module.scss' {
2
+ const content: { [className: string]: string }
3
+ export = content
4
+ }
5
+
6
+ declare module '*.svg' {
7
+ const content: string;
8
+ export default content;
9
+ }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "baseUrl": ".",
3
4
  "target": "ESNext",
4
5
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
6
  "skipLibCheck": true,
@@ -13,7 +14,12 @@
13
14
  "resolveJsonModule": true,
14
15
  "isolatedModules": true,
15
16
  "noEmit": true,
16
- "jsx": "react-jsx"
17
+ "jsx": "react-jsx",
18
+ "paths": {
19
+ "~/components/*": ["./components/*"],
20
+ "~/utils/*": ["./utils/*"]
21
+ }
17
22
  },
18
- "include": ["./"]
23
+ "include": ["./"],
24
+ "files": ["./index.d.ts"]
19
25
  }
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import p from"node:process";import{promises as c,existsSync as h}from"node:fs";import y from"node:url";import e from"node:path";import{spawn as P}from"node:child_process";import{program as l}from"commander";import k from"prompts";import{promises as u}from"node:fs";async function g(t,o,...a){let[s,m]=a,n=await u.readFile(t,s),r=o(n),i=a.length===2?m:s;return await u.writeFile(t,r,i),r}var x=y.fileURLToPath(import.meta.url),j=e.dirname(x),f=p.cwd();l.name("@design-edito/make-template").description("Generate in cwd a project template");l.command("html").description("make simple html project structure").action(S);l.command("react").description("make react + typescript project structure").action(N);l.parse(p.argv);async function S(){let t=e.join(j,"assets/html");if(!h(t))return console.error(`Could not find the template to copy at ${t}`),p.exit(1);let o=e.join(f,"html-template");await c.cp(t,o,{recursive:!0})}async function N(){let t=e.join(j,"assets/react");if(!h(t))return console.error(`Could not find the template to copy at ${t}`),p.exit(1);let o=e.join(f,"react-template");await c.cp(t,o,{recursive:!0});let{projectName:a}=await k({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),s=e.join(o,"package.json");await g(s,r=>{let i=typeof r=="string"?r:r.toString(),d=JSON.parse(i);delete d.name;let w={name:a,...d};return`${JSON.stringify(w,null,2)}
3
- `},{encoding:"utf-8"});let m=P(`cd ${o} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,i)=>{m.on("exit",()=>r(!0)),m.on("error",()=>i(!1))});let n=e.join(f,a);await c.rename(o,n),await c.rename(e.join(n,"gitignore"),e.join(n,".gitignore"))}
2
+ import n from"node:process";import{promises as a,existsSync as d}from"node:fs";import j from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as i}from"commander";import y from"prompts";import P from"@design-edito/tools/utils/node/read-write-file";var k=j.fileURLToPath(import.meta.url),u=t.dirname(k),c=n.cwd();i.name("@design-edito/make-template").description("Generate in cwd a project template");i.command("html").description("make simple html project structure").action(x);i.command("react").description("make react + typescript project structure").action(S);i.parse(n.argv);async function x(){let e=t.join(u,"assets/html");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"html-template");await a.cp(e,o,{recursive:!0})}async function S(){let e=t.join(u,"assets/react");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"react-template");await a.cp(e,o,{recursive:!0});let{projectName:p}=await y({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),g=t.join(o,"package.json");await P(g,r=>{let s=typeof r=="string"?r:r.toString(),f=JSON.parse(s);delete f.name;let h={name:p,...f};return`${JSON.stringify(h,null,2)}
3
+ `},{encoding:"utf-8"});let l=w(`cd ${o} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,s)=>{l.on("exit",()=>r(!0)),l.on("error",()=>s(!1))});let m=t.join(c,p);await a.rename(o,m),await a.rename(t.join(m,"gitignore"),t.join(m,".gitignore"))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/cli",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -16,12 +16,12 @@
16
16
  "make-template": "./make-template/index.js"
17
17
  },
18
18
  "dependencies": {
19
+ "@design-edito/tools": "^0.0.27",
19
20
  "commander": "^12.0.0",
20
21
  "prompts": "^2.4.2"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@commander-js/extra-typings": "^12.0.1",
24
- "@design-edito/tools": "^0.0.19",
25
25
  "@types/node": "^20.11.30",
26
26
  "@types/prompts": "^2.4.9",
27
27
  "@types/semver": "^7.5.8",