@design-edito/cli 0.0.78 → 0.0.80

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.
Files changed (55) hide show
  1. package/cli/assets/list.txt +1 -2
  2. package/cli/assets/version.txt +1 -1
  3. package/make-template/assets/express/esbuild.config.js +19 -0
  4. package/make-template/assets/express/package.json +16 -12
  5. package/make-template/assets/express/src/index.ts +13 -49
  6. package/make-template/assets/express/src/public/index.css +7 -0
  7. package/make-template/assets/express/src/public/index.html +15 -0
  8. package/make-template/assets/express/src/public/index.js +31 -0
  9. package/make-template/assets/express/src/tsconfig.json +7 -3
  10. package/make-template/assets/express/src/www/index.ts +42 -0
  11. package/make-template/assets/express-api/Dockerfile +18 -0
  12. package/make-template/assets/express-api/Dockerfile.dev +8 -0
  13. package/make-template/assets/express-api/env +36 -0
  14. package/make-template/assets/express-api/esbuild.config.js +26 -0
  15. package/make-template/assets/express-api/gitignore +214 -0
  16. package/make-template/assets/express-api/package.json +60 -0
  17. package/make-template/assets/express-api/src/api/auth/_utils/index.ts +47 -0
  18. package/make-template/assets/express-api/src/api/auth/index.ts +25 -0
  19. package/make-template/assets/express-api/src/api/auth/login/index.ts +101 -0
  20. package/make-template/assets/express-api/src/api/auth/logout/index.ts +45 -0
  21. package/make-template/assets/express-api/src/api/auth/refresh-token/index.ts +54 -0
  22. package/make-template/assets/express-api/src/api/auth/request-email-verification-token/index.ts +45 -0
  23. package/make-template/assets/express-api/src/api/auth/request-new-password/index.ts +62 -0
  24. package/make-template/assets/express-api/src/api/auth/signup/index.ts +99 -0
  25. package/make-template/assets/express-api/src/api/auth/submit-new-password/index.ts +61 -0
  26. package/make-template/assets/express-api/src/api/auth/verify-email/index.ts +79 -0
  27. package/make-template/assets/express-api/src/api/auth/whoami/index.ts +68 -0
  28. package/make-template/assets/express-api/src/api/index.ts +18 -0
  29. package/make-template/assets/express-api/src/api/types.ts +76 -0
  30. package/make-template/assets/express-api/src/api/utils.ts +146 -0
  31. package/make-template/assets/express-api/src/database/index.ts +173 -0
  32. package/make-template/assets/express-api/src/email/index.ts +47 -0
  33. package/make-template/assets/express-api/src/env/index.ts +77 -0
  34. package/make-template/assets/express-api/src/errors/index.ts +128 -0
  35. package/make-template/assets/express-api/src/index.ts +42 -0
  36. package/make-template/assets/express-api/src/init/index.ts +156 -0
  37. package/make-template/assets/express-api/src/jwt/index.ts +105 -0
  38. package/make-template/assets/express-api/src/public/index.css +7 -0
  39. package/make-template/assets/express-api/src/public/index.html +15 -0
  40. package/make-template/assets/express-api/src/public/index.js +31 -0
  41. package/make-template/assets/express-api/src/schema/_history/index.ts +124 -0
  42. package/make-template/assets/express-api/src/schema/_meta/index.ts +113 -0
  43. package/make-template/assets/express-api/src/schema/index.ts +17 -0
  44. package/make-template/assets/express-api/src/schema/user/index.ts +117 -0
  45. package/make-template/assets/express-api/src/schema/user-email-validation-token/index.ts +20 -0
  46. package/make-template/assets/express-api/src/schema/user-password-renewal-token/index.ts +20 -0
  47. package/make-template/assets/express-api/src/schema/user-revoked-auth-token/index.ts +26 -0
  48. package/make-template/assets/express-api/src/tsconfig.json +16 -0
  49. package/make-template/assets/express-api/src/www/index.ts +43 -0
  50. package/make-template/index.js +2 -3
  51. package/make-template/index.js.map +3 -3
  52. package/package.json +7 -8
  53. package/make-template/assets/express/src/routes/index.ts +0 -7
  54. package/upgrade/index.js +0 -12
  55. package/upgrade/index.js.map +0 -7
@@ -0,0 +1,113 @@
1
+ import {
2
+ Types as MongooseTypes,
3
+ Schema as MongooseSchema,
4
+ CallbackWithoutResultAndOptionalError as MongooseCallbackWithoutResultAndOptionalError,
5
+ UpdateQuery as MongooseUpdateQuery
6
+ } from 'mongoose'
7
+ import { DocumentWithLocals, QueryWithLocals } from '../../database'
8
+ import { ROOT_USER_ID } from '../../env'
9
+ import { unknownToString } from '@design-edito/tools/agnostic/errors/unknown-to-string'
10
+
11
+ // Document
12
+ export type IMeta = {
13
+ creationTime: Date
14
+ creatorId: MongooseTypes.ObjectId
15
+ lastUpdationTime: Date
16
+ lastUpdaterId: MongooseTypes.ObjectId
17
+ currentVersionNumber: number
18
+ }
19
+ export type WithMeta<T> = T & { _meta: IMeta }
20
+ export type WithoutMeta<T> = Omit<T, '_meta'> & { _meta?: undefined }
21
+
22
+ // Schema
23
+ export const MetaSchema = new MongooseSchema<IMeta>({
24
+ creationTime: { type: Date, required: true },
25
+ creatorId: { type: MongooseSchema.ObjectId, required: true },
26
+ lastUpdationTime: { type: Date, required: true },
27
+ lastUpdaterId: { type: MongooseSchema.ObjectId, required: true },
28
+ currentVersionNumber: { type: Number, required: true }
29
+ })
30
+
31
+ export function withMeta<T extends Object> (inputSchema: MongooseSchema<T>): MongooseSchema<WithMeta<T>> {
32
+ const schema = inputSchema.clone() as MongooseSchema<WithMeta<T>>
33
+ schema.add(new MongooseSchema<WithMeta<{}>>({
34
+ _meta: {
35
+ type: MetaSchema,
36
+ required: true,
37
+ default: {
38
+ creationTime: new Date(),
39
+ creatorId: new MongooseTypes.ObjectId(ROOT_USER_ID),
40
+ lastUpdationTime: new Date(),
41
+ lastUpdaterId: new MongooseTypes.ObjectId(ROOT_USER_ID),
42
+ currentVersionNumber: 0
43
+ }
44
+ }
45
+ }))
46
+ schema.pre('save', handleSave)
47
+ schema.pre('insertMany', handleInsertMany)
48
+ schema.pre('updateOne', handleUpdate)
49
+ schema.pre('findOneAndUpdate', handleUpdate)
50
+
51
+ function handleSave (
52
+ this: WithMeta<DocumentWithLocals<{}>>,
53
+ next: MongooseCallbackWithoutResultAndOptionalError
54
+ ) {
55
+ const context = this.$locals?.context
56
+ const initiatorId = context?.initiatorId ?? null
57
+ const initiatorObjectId = initiatorId !== null ? new MongooseTypes.ObjectId(initiatorId) : null
58
+ if (initiatorObjectId === null) return next(new Error('initiatorId is required in context for save operation.'))
59
+ if (this.isNew) {
60
+ this._meta.creationTime = new Date()
61
+ this._meta.creatorId = initiatorObjectId
62
+ }
63
+ this._meta.lastUpdationTime = new Date()
64
+ this._meta.lastUpdaterId = initiatorObjectId
65
+ this._meta.currentVersionNumber = 0
66
+ next()
67
+ }
68
+
69
+ function handleInsertMany (
70
+ next: MongooseCallbackWithoutResultAndOptionalError,
71
+ docs: Array<WithMeta<DocumentWithLocals<{}>>>
72
+ ) {
73
+ try {
74
+ for (const doc of docs) {
75
+ const context = doc.$locals?.context
76
+ const initiatorId = context?.initiatorId ?? null
77
+ const initiatorObjectId = initiatorId !== null ? new MongooseTypes.ObjectId(initiatorId) : null
78
+ if (initiatorObjectId === null) return next(new Error('initiatorId is required in context for insertMany operation.'))
79
+ doc._meta.creationTime = new Date()
80
+ doc._meta.creatorId = initiatorObjectId
81
+ doc._meta.lastUpdationTime = new Date()
82
+ doc._meta.lastUpdaterId = initiatorObjectId
83
+ doc._meta.currentVersionNumber = 0
84
+ }
85
+ next()
86
+ } catch (err) {
87
+ const errStr = unknownToString(err)
88
+ next(new Error(errStr))
89
+ }
90
+ }
91
+
92
+ function handleUpdate (
93
+ this: QueryWithLocals<WithMeta<{}>>,
94
+ next: MongooseCallbackWithoutResultAndOptionalError
95
+ ) {
96
+ const context = this.getOptions().$locals?.context
97
+ const initiatorId = context?.initiatorId ?? null
98
+ const initiatorObjectId = initiatorId !== null ? new MongooseTypes.ObjectId(initiatorId) : null
99
+ if (initiatorObjectId === null) return next(new Error('initiatorId is required in context for save operation.'))
100
+ const rawUpdate = this.getUpdate()
101
+ if (Array.isArray(rawUpdate)) return next(new Error('Aggregation pipeline updates are not supported in this hook.'))
102
+ const update: MongooseUpdateQuery<WithMeta<{}>> = (rawUpdate ?? {}) as MongooseUpdateQuery<WithMeta<{}>>
103
+ update.$set = update.$set ?? {}
104
+ update.$inc = update.$inc ?? {}
105
+ update.$set['_meta.lastUpdationTime'] = new Date()
106
+ update.$set['_meta.lastUpdaterId'] = initiatorObjectId
107
+ update.$inc['_meta.currentVersionNumber'] = ((update.$inc['_meta.currentVersionNumber'] as number) ?? 0) + 1
108
+ this.setUpdate(update)
109
+ next()
110
+ }
111
+
112
+ return schema
113
+ }
@@ -0,0 +1,17 @@
1
+ import { Schema as MongooseSchema, model as mongooseModel } from 'mongoose'
2
+ import { Outcome } from '@design-edito/tools/agnostic/misc/outcome'
3
+ import { unknownToString } from '@design-edito/tools/agnostic/errors/unknown-to-string'
4
+
5
+ export async function validate<T> (
6
+ schema: MongooseSchema<T>,
7
+ object: unknown
8
+ ): Promise<Outcome.Either<T, string>> {
9
+ const Model = mongooseModel('', schema)
10
+ const doc = new Model(object)
11
+ try {
12
+ await doc.validate()
13
+ return Outcome.makeSuccess(object as T)
14
+ } catch (err) {
15
+ return Outcome.makeFailure(unknownToString(err))
16
+ }
17
+ }
@@ -0,0 +1,117 @@
1
+ import {
2
+ Schema as MongooseSchema,
3
+ model as mongooseModel,
4
+ Document as MongooseDocument,
5
+ ValidatorProps as MongooseValidatorProps
6
+ } from 'mongoose'
7
+ import { isEmail, isSlug } from 'validator'
8
+ import * as _History from '../_history'
9
+ import * as _Meta from '../_meta'
10
+
11
+ // Imports
12
+ type WithHistory<T> = _History.WithHistory<T>
13
+ type WithMeta<T> = _Meta.WithMeta<T>
14
+
15
+ const { withHistory } = _History
16
+ const { withMeta } = _Meta
17
+
18
+ export enum Role {
19
+ ROOT = 'root',
20
+ ADMIN = 'admin',
21
+ USER = 'user'
22
+ }
23
+
24
+ export enum Status {
25
+ ACTIVE = 'active',
26
+ SUSPENDED = 'suspended',
27
+ BANNED = 'banned'
28
+ }
29
+
30
+ // Document
31
+ export type IBaseUserCore = {
32
+ username: string
33
+ role: Role
34
+ status: Status
35
+ }
36
+
37
+ export type IGoogleUserCore = IBaseUserCore & {
38
+ googleId: string
39
+ }
40
+
41
+ export type ILocalUserCore = IBaseUserCore & {
42
+ email: string
43
+ password: string
44
+ verified: boolean
45
+ }
46
+
47
+ export type IBaseUser = WithMeta<WithHistory<IBaseUserCore>>
48
+ export type IGoogleUser = WithMeta<WithHistory<IGoogleUserCore>>
49
+ export type ILocalUser = WithMeta<WithHistory<ILocalUserCore>>
50
+
51
+ export type IUser = IGoogleUser | ILocalUser
52
+
53
+ // Schema
54
+ const emailValidator = (input: string) => isEmail(input)
55
+ const emailValidationErrMessage = (props: MongooseValidatorProps) => `${props.value} is not a valid email address.`
56
+ const usernameValidator = (input: string) => isSlug(input.toLowerCase())
57
+ const usernameValidationErrMessage = (props: MongooseValidatorProps) => `${props.value} is not a valid username. Alphanumeric, hyphens and underscore (non starting nor trailing, non consecutive) characters only.`
58
+
59
+ export const BaseUserCoreSchema = new MongooseSchema<IBaseUserCore>({
60
+ username: {
61
+ type: String,
62
+ required: true,
63
+ unique: true,
64
+ validate: {
65
+ validator: usernameValidator,
66
+ message: usernameValidationErrMessage
67
+ }
68
+ },
69
+ role: {
70
+ type: String,
71
+ enum: Object.values(Role),
72
+ required: true,
73
+ default: Role.USER
74
+ },
75
+ status: {
76
+ type: String,
77
+ enum: Object.values(Status),
78
+ required: true,
79
+ default: Status.ACTIVE
80
+ }
81
+ }, { discriminatorKey: 'authType', _id: false })
82
+
83
+ export const BaseUserSchema: MongooseSchema<IBaseUser> = withMeta(withHistory(BaseUserCoreSchema))
84
+
85
+ export const LocalUserCoreSchema = new MongooseSchema<ILocalUserCore>({
86
+ email: {
87
+ type: String,
88
+ required: true,
89
+ unique: true,
90
+ validate: {
91
+ validator: emailValidator,
92
+ message: emailValidationErrMessage
93
+ }
94
+ },
95
+ password: {
96
+ type: String,
97
+ required: true
98
+ },
99
+ verified: {
100
+ type: Boolean,
101
+ required: true,
102
+ default: false
103
+ }
104
+ })
105
+
106
+ export const GoogleUserCoreSchema = new MongooseSchema<IGoogleUserCore>({
107
+ googleId: {
108
+ type: String,
109
+ required: true,
110
+ unique: true
111
+ }
112
+ })
113
+
114
+ // Models
115
+ export const BaseUserModel = mongooseModel<IBaseUser>('User', BaseUserSchema)
116
+ export const LocalUserModel = BaseUserModel.discriminator<ILocalUser>('LocalUser', LocalUserCoreSchema)
117
+ export const GoogleUserModel = BaseUserModel.discriminator<IGoogleUser>('GoogleUser', GoogleUserCoreSchema)
@@ -0,0 +1,20 @@
1
+ import {
2
+ Schema as MongooseSchema,
3
+ model as mongooseModel
4
+ } from 'mongoose'
5
+
6
+ // Document
7
+ export type IUserEmailValidationToken = {
8
+ value: string
9
+ email: string
10
+ expiresOn: Date
11
+ }
12
+
13
+ export const UserEmailValidationTokenSchema = new MongooseSchema<IUserEmailValidationToken>({
14
+ value: { type: String, required: true },
15
+ email: { type: String, required: true },
16
+ expiresOn: { type: Date, required: true }
17
+ })
18
+
19
+ // Models
20
+ export const UserEmailValidationTokenModel = mongooseModel<IUserEmailValidationToken>('UserEmailValidationToken', UserEmailValidationTokenSchema)
@@ -0,0 +1,20 @@
1
+ import {
2
+ Schema as MongooseSchema,
3
+ model as mongooseModel
4
+ } from 'mongoose'
5
+
6
+ // Document
7
+ export type IUserPasswordRenewalToken = {
8
+ value: string
9
+ email: string
10
+ expiresOn: Date
11
+ }
12
+
13
+ export const UserPasswordRenewalTokenSchema = new MongooseSchema<IUserPasswordRenewalToken>({
14
+ value: { type: String, required: true },
15
+ email: { type: String, required: true },
16
+ expiresOn: { type: Date, required: true }
17
+ })
18
+
19
+ // Models
20
+ export const UserPasswordRenewalTokenModel = mongooseModel<IUserPasswordRenewalToken>('UserPasswordRenewalToken', UserPasswordRenewalTokenSchema)
@@ -0,0 +1,26 @@
1
+ import {
2
+ Schema as MongooseSchema,
3
+ model as mongooseModel
4
+ } from 'mongoose'
5
+
6
+ // Document
7
+ export type IUserRevokedToken = {
8
+ value: string
9
+ revokedOn: Date
10
+ }
11
+
12
+ // Schema
13
+ export const UserRevokedTokenSchema = new MongooseSchema<IUserRevokedToken>({
14
+ value: {
15
+ type: String,
16
+ required: true,
17
+ unique: true
18
+ },
19
+ revokedOn: {
20
+ type: Date,
21
+ required: true
22
+ }
23
+ })
24
+
25
+ // Model
26
+ export const UserRevokedTokenModel = mongooseModel<IUserRevokedToken>('UserRevokedToken', UserRevokedTokenSchema)
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "esModuleInterop": true,
7
+ "declaration": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "strictNullChecks": true,
13
+ "noEmit": true
14
+ },
15
+ "include": ["./**/*"]
16
+ }
@@ -0,0 +1,43 @@
1
+ import http from 'node:http'
2
+ import debugModule from 'debug'
3
+ import { Express } from 'express'
4
+ import { shutdown } from '../init'
5
+
6
+ interface NodeError extends Error {
7
+ syscall?: string
8
+ code?: string
9
+ }
10
+
11
+ export function serve (app: Express) {
12
+ const port = normalizePort(process.env.PORT ?? '3000')
13
+ const debug = debugModule('<<@mxfb/cli----replace-with-name>>:server')
14
+ const server = http.createServer(app)
15
+ app.set('port', port)
16
+ server.listen(port)
17
+ server.on('error', (error: NodeError) => {
18
+ if (error.syscall !== 'listen') throw error
19
+ var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port
20
+ switch (error.code) {
21
+ case 'EACCES':
22
+ console.error(bind + ' requires elevated privileges')
23
+ return shutdown(1)
24
+ case 'EADDRINUSE':
25
+ console.error(bind + ' is already in use')
26
+ return shutdown(1)
27
+ default:
28
+ throw error
29
+ }
30
+ })
31
+ server.on('listening', () => {
32
+ var addr = server.address()
33
+ var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + (addr?.port ?? '')
34
+ debug('Listening on ' + bind)
35
+ })
36
+
37
+ function normalizePort (val: string) {
38
+ var port = parseInt(val, 10)
39
+ if (isNaN(port)) return val
40
+ if (port >= 0) return port
41
+ return false
42
+ }
43
+ }
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import l from"node:process";import{promises as i,existsSync as j}from"node:fs";import P from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as d}from"commander";import x from"prompts";import{Files as f}from"@design-edito/tools/node/files/index.js";var k=P.fileURLToPath(import.meta.url),h=t.dirname(k),p=l.cwd();d.name("@design-edito/make-template").description("Generate in cwd a project template");d.command("express").description("make express.js + typescript project structure").action(N);d.command("html").description("make simple html project structure").action(S);d.command("react").description("make react + typescript project structure").action(b);d.parse(l.argv);async function S(){let o=t.join(h,"assets/html");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"html-template");await i.cp(o,n,{recursive:!0})}async function b(){let o=t.join(h,"assets/react");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"react-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await x({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,r=>{let e=typeof r=="string"?r:r.toString(),a=JSON.parse(e);delete a.name;let m={name:s,...a};return`${JSON.stringify(m,null,2)}
3
- `},{encoding:"utf-8"});let g=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,e)=>{g.on("exit",()=>r(!0)),g.on("error",()=>e(!1))});let c=t.join(p,s);await i.rename(n,c),await i.rename(t.join(c,"gitignore"),t.join(c,".gitignore"))}async function N(){let o=t.join(h,"assets/express");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"express-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await x({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,e=>{let a=typeof e=="string"?e:e.toString(),m=JSON.parse(a);delete m.name;let y={name:s,...m};return`${JSON.stringify(y,null,2)}
4
- `},{encoding:"utf-8"});let g=t.join(n,"src/index.ts");await f.readWrite(g,e=>(typeof e=="string"?e:e.toString()).replace("<<@mxfb/cli----replace-with-name>>",s),{encoding:"utf-8"});let c=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((e,a)=>{c.on("exit",()=>e(!0)),c.on("error",()=>a(!1))});let r=t.join(p,s);await i.rename(n,r),await i.rename(t.join(r,"gitignore"),t.join(r,".gitignore"))}
2
+ import l from"node:process";import{promises as a,existsSync as f}from"node:fs";import y from"node:url";import e from"node:path";import{spawn as h}from"node:child_process";import{program as u}from"commander";import w from"prompts";import{Files as d}from"@design-edito/tools/node/files/index.js";var P=y.fileURLToPath(import.meta.url),j=e.dirname(P),p=l.cwd();u.name("@design-edito/make-template").description("Generate in cwd a project template");u.command("express").description("make express.js + typescript project structure").action(b);u.command("express-api").description("make express.js + typescript + docker project structure for a quick API setup").action(T);u.command("html").description("make simple html project structure").action(k);u.command("react").description("make react + typescript project structure").action(S);u.parse(l.argv);async function k(){let o=e.join(j,"assets/html");if(!f(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=e.join(p,"html-template");await a.cp(o,n,{recursive:!0})}async function S(){let o=e.join(j,"assets/react");if(!f(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=e.join(p,"react-template");await a.cp(o,n,{recursive:!0});let{projectName:i}=await w({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),g=e.join(n,"package.json");await d.readWrite(g,r=>{let t=typeof r=="string"?r:r.toString(),s=JSON.parse(t);delete s.name;let x={name:i,...s};return`${JSON.stringify(x,null,2)}
3
+ `},{encoding:"utf-8"});let m=h(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,t)=>{m.on("exit",()=>r(!0)),m.on("error",()=>t(!1))});let c=e.join(p,i);await a.rename(n,c),await a.rename(e.join(c,"gitignore"),e.join(c,".gitignore"))}async function b(){let o=e.join(j,"assets/express");if(!f(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=e.join(p,"express-template");await a.cp(o,n,{recursive:!0});let{projectName:i}=await w({name:"projectName",message:"Project name ? (lower case a-z, hyphens or underscores only)",type:"text"}),g=e.join(n,"package.json");await d.readWrite(g,t=>(typeof t=="string"?t:t.toString()).replaceAll("<<@mxfb/cli----replace-with-name>>",i),{encoding:"utf-8"});let m=e.join(n,"src/www/index.ts");await d.readWrite(m,t=>(typeof t=="string"?t:t.toString()).replaceAll("<<@mxfb/cli----replace-with-name>>",i),{encoding:"utf-8"});let c=h(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((t,s)=>{c.on("exit",()=>t(!0)),c.on("error",()=>s(!1))});let r=e.join(p,i);await a.rename(n,r),await a.rename(e.join(r,"gitignore"),e.join(r,".gitignore"))}async function T(){let o=e.join(j,"assets/express-api");if(!f(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=e.join(p,"express-api-template");await a.cp(o,n,{recursive:!0});let{projectName:i}=await w({name:"projectName",message:"Project name ? (lower case a-z, hyphens or underscores only)",type:"text"}),g=e.join(n,"package.json");await d.readWrite(g,t=>(typeof t=="string"?t:t.toString()).replaceAll("<<@mxfb/cli----replace-with-name>>",i),{encoding:"utf-8"});let m=e.join(n,"src//www/index.ts");await d.readWrite(m,t=>(typeof t=="string"?t:t.toString()).replaceAll("<<@mxfb/cli----replace-with-name>>",i),{encoding:"utf-8"});let c=h(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((t,s)=>{c.on("exit",()=>t(!0)),c.on("error",()=>s(!1))});let r=e.join(p,i);await a.rename(n,r),await a.rename(e.join(r,"gitignore"),e.join(r,".gitignore")),await a.rename(e.join(r,"env"),e.join(r,".env")),console.log("You're all set! Now configure .env file!")}
5
4
  //# sourceMappingURL=index.js.map
@@ -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\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/index.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src/index.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
- "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,EA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A,MAAO,GAAG,KAAK,UAAUC,EAAe,KAAM,CAAC,CAAC;AAAA,CAClD,EAAG,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMK,EAAiBzB,EAAK,KAAKc,EAAmB,cAAc,EAClE,MAAMV,EAAM,UAAUqB,EAAgBR,IACZ,OAAOA,GAAe,SAC1CA,EACAA,EAAW,SAAS,GACe,QAAQ,qCAAsCF,CAAW,EAE/F,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMM,EAAiBpB,EAAM,MAAMa,CAAiB,YAAa,CAAE,MAAO,UAAW,MAAO,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
- "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"]
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('express-api')\n .description('make express.js + typescript + docker project structure for a quick API setup')\n .action(makeExpressApi)\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\n/* * * * * * * * * * * * * * * * * * *\n *\n * HTML\n *\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\n/* * * * * * * * * * * * * * * * * * *\n *\n * REACT\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\n/* * * * * * * * * * * * * * * * * * *\n *\n * EXPRESS\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 ? (lower case a-z, hyphens or underscores only)',\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 return content.replaceAll('<<@mxfb/cli----replace-with-name>>', projectName)\n }, { encoding: 'utf-8' })\n\n // Custom project name in src/www/index.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src/www/index.ts')\n await Files.readWrite(binStartTsPath, rawContent => {\n const originalContent = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n return originalContent.replaceAll('<<@mxfb/cli----replace-with-name>>', projectName)\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(path.join(targetPath, 'gitignore'), path.join(targetPath, '.gitignore'))\n}\n\n/* * * * * * * * * * * * * * * * * * *\n *\n * EXPRESS API\n *\n * * * * * * * * * * * * * * * * * * */\nasync function makeExpressApi () {\n const expressTemplatePath = path.join(__dirname, 'assets/express-api')\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-api-template')\n\n // Copy\n await fs.cp(expressTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (lower case a-z, hyphens or underscores only)',\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 return content.replaceAll('<<@mxfb/cli----replace-with-name>>', projectName)\n }, { encoding: 'utf-8' })\n\n // Custom project name in src/www/index.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src//www/index.ts')\n await Files.readWrite(binStartTsPath, rawContent => {\n const originalContent = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n return originalContent.replaceAll('<<@mxfb/cli----replace-with-name>>', projectName)\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(path.join(targetPath, 'gitignore'), path.join(targetPath, '.gitignore'))\n await fs.rename(path.join(targetPath, 'env'), path.join(targetPath, '.env'))\n\n console.log('You\\'re all set! Now configure .env file!')\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,O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T,WAAW,qCAAsCF,CAAW,EAC1E,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMU,EAAiB1B,EAAK,KAAKe,EAAmB,mBAAmB,EACvE,MAAMX,EAAM,UAAUsB,EAAgBR,IACZ,OAAOA,GAAe,SAC1CA,EACAA,EAAW,SAAS,GACD,WAAW,qCAAsCF,CAAW,EAClF,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMM,EAAiBrB,EAAM,MAAMc,CAAiB,YAAa,CAAE,MAAO,UAAW,MAAO,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,EAAab,EAAK,KAAKO,EAAKS,CAAW,EAC7C,MAAMnB,EAAG,OAAOkB,EAAmBF,CAAU,EAG7C,MAAMhB,EAAG,OAAOG,EAAK,KAAKa,EAAY,WAAW,EAAGb,EAAK,KAAKa,EAAY,YAAY,CAAC,EACvF,MAAMhB,EAAG,OAAOG,EAAK,KAAKa,EAAY,KAAK,EAAGb,EAAK,KAAKa,EAAY,MAAM,CAAC,EAE3E,QAAQ,IAAI,0CAA2C,CACzD",
6
+ "names": ["process", "fs", "existsSync", "url", "path", "spawn", "program", "prompts", "Files", "__filename", "__dirname", "CWD", "makeExpress", "makeExpressApi", "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.78",
3
+ "version": "0.0.80",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -14,21 +14,20 @@
14
14
  "bin": {
15
15
  "cli": "./cli/index.js",
16
16
  "make-template": "./make-template/index.js",
17
- "upgrade": "./upgrade/index.js",
18
17
  "tree": "./tree/index.js"
19
18
  },
20
19
  "dependencies": {
21
- "@design-edito/tools": "^0.1.8",
20
+ "@design-edito/tools": "^0.1.48",
22
21
  "commander": "^12.1.0",
23
22
  "prompts": "^2.4.2"
24
23
  },
25
24
  "devDependencies": {
26
- "@types/node": "^22.5.5",
25
+ "@types/node": "^22.13.4",
27
26
  "@types/prompts": "^2.4.9",
28
27
  "@types/semver": "^7.5.8",
29
- "esbuild": "^0.23.1",
30
- "semver": "^7.6.3",
31
- "simple-git": "^3.26.0",
32
- "typescript": "^5.6.2"
28
+ "esbuild": "^0.25.0",
29
+ "semver": "^7.7.1",
30
+ "simple-git": "^3.27.0",
31
+ "typescript": "^5.7.3"
33
32
  }
34
33
  }
@@ -1,7 +0,0 @@
1
- import express from 'express'
2
- const router = express.Router()
3
-
4
- /* GET home page. */
5
- router.get('/', (req, res, next) => res.send({ data: true }))
6
-
7
- export default router
package/upgrade/index.js DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- import{spawn as n}from"node:child_process";import t from"node:process";import{program as l}from"commander";import c from"prompts";import{Logs as e}from"@design-edito/tools/agnostic/misc/logs/index.js";var o={title:e.styles.title("Global upgrade of @design-edito/cli"),installed:e.styles.info(`
3
- Currently installed NPM packages:
4
- `),listError:e.styles.error(`
5
- Something went wrong while listing the globally installed NPM packages. Aborting.`),confirm:"You may be prompted for your sudo password to complete the installation. Do you want to continue?",aborting:e.styles.error(`
6
- Aborting.`),installing:e.styles.important(`Installing @design-edito/cli globally...
7
- `),success:e.styles.success(`
8
- Success.
9
- `),installationError:e.styles.error(`
10
- Installation failed. Please check your permissions and try again.
11
- `)};l.name("@design-edito/upgrade").description("Upgrades @design-edito/cli to the latest version available").action(async()=>{console.log(o.title),console.log(o.installed),n("npm",["list","-g"],{stdio:"inherit"}).on("exit",async s=>{if(s!==0)return console.log(o.listError),t.exit(s);let{proceedUpgrade:r}=await c({name:"proceedUpgrade",type:"confirm",message:o.confirm});if(r!==!0)return console.log(o.aborting),t.exit(1);console.log("");let a=n("sudo",["npm","i","-g","@design-edito/cli"],{stdio:"inherit"});console.log(o.installing),a.on("exit",i=>{i===0?console.log(o.success):(console.error(o.installationError),t.exit(i))})})});l.parse(t.argv);
12
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/upgrade/index.ts"],
4
- "sourcesContent": ["import { spawn } from 'node:child_process'\nimport process from 'node:process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Logs } from '@design-edito/tools/agnostic/misc/logs/index.js'\n\nconst logged = {\n title: Logs.styles.title('Global upgrade of @design-edito/cli'),\n installed: Logs.styles.info('\\nCurrently installed NPM packages:\\n'),\n listError: Logs.styles.error('\\nSomething went wrong while listing the globally installed NPM packages. Aborting.'),\n confirm: 'You may be prompted for your sudo password to complete the installation. Do you want to continue?',\n aborting: Logs.styles.error('\\nAborting.'),\n installing: Logs.styles.important('Installing @design-edito/cli globally...\\n'),\n success: Logs.styles.success('\\nSuccess.\\n'),\n installationError: Logs.styles.error('\\nInstallation failed. Please check your permissions and try again.\\n')\n}\n\nprogram\n .name('@design-edito/upgrade')\n .description('Upgrades @design-edito/cli to the latest version available')\n .action(async () => {\n console.log(logged.title)\n console.log(logged.installed)\n const child1 = spawn('npm', ['list', '-g'], { stdio: 'inherit' })\n child1.on('exit', async code => {\n if (code !== 0) {\n console.log(logged.listError)\n return process.exit(code)\n }\n const { proceedUpgrade } = await prompts({\n name: 'proceedUpgrade',\n type: 'confirm',\n message: logged.confirm\n })\n if (proceedUpgrade !== true) {\n console.log(logged.aborting)\n return process.exit(1)\n }\n console.log('')\n const child2 = spawn('sudo', ['npm', 'i', '-g', '@design-edito/cli'], { stdio: 'inherit' })\n console.log(logged.installing)\n child2.on('exit', code => {\n if (code === 0) console.log(logged.success)\n else {\n console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