@design-edito/cli 0.0.71 → 0.0.74
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/cli/assets/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.74
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build:src": "npx esbuild --bundle src/
|
|
7
|
+
"build:src": "npx esbuild --bundle src/index.ts --outdir=dist --sourcemap --platform=node --format=esm --external:debug --external:express --external:cookie-parser --external:morgan",
|
|
8
8
|
"watch:src": "npm run build:src && npx chokidar 'src/**/*' -c 'npm run build:src'",
|
|
9
|
-
"serve": "npx nodemon ./dist/
|
|
9
|
+
"serve": "npx nodemon ./dist/index.js",
|
|
10
10
|
"start:nowatch": "npm run build:src && npm run serve",
|
|
11
11
|
"start": "npx concurrently -n 'watch:src ,serve ' 'npm run watch:src' 'npm run serve'"
|
|
12
12
|
},
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import http from 'node:http'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import express from 'express'
|
|
5
|
+
import cookieParser from 'cookie-parser'
|
|
6
|
+
import logger from 'morgan'
|
|
2
7
|
import debugModule from 'debug'
|
|
3
|
-
import
|
|
8
|
+
import indexRouter from './routes/index.js'
|
|
4
9
|
|
|
5
10
|
const debug = debugModule('<<@mxfb/cli----replace-with-name>>:server')
|
|
6
11
|
const port = normalizePort(process.env.PORT ?? '3000')
|
|
7
|
-
|
|
12
|
+
const app = express()
|
|
13
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
14
|
+
|
|
15
|
+
app.use(logger('dev'))
|
|
16
|
+
app.use(express.json())
|
|
17
|
+
app.use(express.urlencoded({ extended: false }))
|
|
18
|
+
app.use(cookieParser())
|
|
19
|
+
app.use(express.static(path.join(__dirname, 'public')))
|
|
20
|
+
app.use('/', indexRouter)
|
|
8
21
|
app.set('port', port)
|
|
9
22
|
|
|
10
23
|
const server = http.createServer(app)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/make-template/index.ts"],
|
|
4
|
-
"sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Files } from '@design-edito/tools/node/files/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n\nprogram\n .command('express')\n .description('make express.js + typescript project structure')\n .action(makeExpress)\n
|
|
4
|
+
"sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Files } from '@design-edito/tools/node/files/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n\nprogram\n .command('express')\n .description('make express.js + typescript project structure')\n .action(makeExpress)\n\nprogram\n .command('html')\n .description('make simple html project structure')\n .action(makeHtml)\n\nprogram\n .command('react')\n .description('make react + typescript project structure')\n .action(makeReact)\n\nprogram.parse(process.argv)\n\nasync function makeHtml () {\n const htmlTemplatePath = path.join(__dirname, 'assets/html')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const targetPath = path.join(CWD, 'html-template')\n await fs.cp(htmlTemplatePath, targetPath, { recursive: true })\n}\n\nasync function makeReact () {\n const reactTemplatePath = path.join(__dirname, 'assets/react')\n if (!existsSync(reactTemplatePath)) {\n console.error(`Could not find the template to copy at ${reactTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'react-template')\n \n // Copy\n await fs.cp(reactTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n\nasync function makeExpress () {\n const expressTemplatePath = path.join(__dirname, 'assets/express')\n if (!existsSync(expressTemplatePath)) {\n console.error(`Could not find the template to copy at ${expressTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'express-template')\n \n // Copy\n await fs.cp(expressTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name in package.json\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n\n // Custom project name in src/bin/start.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src/bin/start.ts')\n await Files.readWrite(binStartTsPath, rawContent => {\n const originalContent = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const updatedContent = originalContent.replace('<<@mxfb/cli----replace-with-name>>', projectName)\n return updatedContent\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAS,SAAAC,MAAa,0CAEtB,IAAMC,EAAaN,EAAI,cAAc,YAAY,GAAG,EAC9CO,EAAYN,EAAK,QAAQK,CAAU,EACnCE,EAAMX,EAAQ,IAAI,EAExBM,EACG,KAAK,6BAA6B,EAClC,YAAY,oCAAoC,EAEnDA,EACG,QAAQ,SAAS,EACjB,YAAY,gDAAgD,EAC5D,OAAOM,CAAW,EAErBN,EACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,OAAOO,CAAQ,EAElBP,EACG,QAAQ,OAAO,EACf,YAAY,2CAA2C,EACvD,OAAOQ,CAAS,EAEnBR,EAAQ,MAAMN,EAAQ,I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AAO,EAAK,CAAC,EAClG,MAAM,IAAI,QAAQ,CAACQ,EAASC,IAAW,CACrCF,EAAe,GAAG,OAAQ,IAAMC,EAAQ,EAAI,CAAC,EAC7CD,EAAe,GAAG,QAAS,IAAME,EAAO,EAAK,CAAC,CAChD,CAAC,EAGD,IAAMX,EAAaZ,EAAK,KAAKO,EAAKQ,CAAW,EAC7C,MAAMlB,EAAG,OAAOiB,EAAmBF,CAAU,EAG7C,MAAMf,EAAG,OACPG,EAAK,KAAKY,EAAY,WAAW,EACjCZ,EAAK,KAAKY,EAAY,YAAY,CACpC,CACF",
|
|
6
6
|
"names": ["process", "fs", "existsSync", "url", "path", "spawn", "program", "prompts", "Files", "__filename", "__dirname", "CWD", "makeExpress", "makeHtml", "makeReact", "htmlTemplatePath", "targetPath", "reactTemplatePath", "defaultTargetPath", "projectName", "packageJsonPath", "rawContent", "content", "contentObj", "newContentObj", "npmISubprocess", "resolve", "reject", "expressTemplatePath", "binStartTsPath"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design-edito/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Maxime Fabas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"main": "index.js",
|
|
13
13
|
"module": "index.js",
|
|
14
14
|
"bin": {
|
|
15
|
-
"cli": "./cli/index.js",
|
|
16
15
|
"make-template": "./make-template/index.js",
|
|
16
|
+
"cli": "./cli/index.js",
|
|
17
17
|
"tree": "./tree/index.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { fileURLToPath } from 'node:url'
|
|
3
|
-
import express from 'express'
|
|
4
|
-
import cookieParser from 'cookie-parser'
|
|
5
|
-
import logger from 'morgan'
|
|
6
|
-
import indexRouter from './routes/index.js'
|
|
7
|
-
|
|
8
|
-
const app = express()
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
|
|
11
|
-
app.use(logger('dev'))
|
|
12
|
-
app.use(express.json())
|
|
13
|
-
app.use(express.urlencoded({ extended: false }))
|
|
14
|
-
app.use(cookieParser())
|
|
15
|
-
app.use(express.static(path.join(__dirname, 'public')))
|
|
16
|
-
app.use('/', indexRouter)
|
|
17
|
-
|
|
18
|
-
export default app
|