nextia 7.0.11 → 7.0.12

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/bin.js +15 -18
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nextia",
3
3
  "description": "Create fast web applications",
4
- "version": "7.0.11",
4
+ "version": "7.0.12",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
package/src/bin.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * https://github.com/sinuhedev/nextia
10
10
  */
11
11
 
12
- import { writeFile } from 'node:fs/promises'
12
+ import { mkdir, writeFile } from 'node:fs/promises'
13
13
 
14
14
  function toPascalCase(str) {
15
15
  return str
@@ -31,7 +31,6 @@ async function createPage(name) {
31
31
  writeFile(
32
32
  `${dirName}/index.jsx`,
33
33
  `import { css, useFx } from 'nextia'
34
- import { useEffect } from 'react'
35
34
  import functions from './functions'
36
35
  import './style.css'
37
36
 
@@ -71,16 +70,15 @@ export default { initialState }
71
70
 
72
71
  async function createComponent(name) {
73
72
  const dirName = `./src/components/${name}`
73
+ const componentName = toPascalCase(name)
74
74
 
75
75
  try {
76
76
  await mkdir(dirName)
77
- const componentName = toPascalCase(name)
78
77
 
79
78
  // index.jsx
80
79
  writeFile(
81
80
  `${dirName}/index.jsx`,
82
81
  `import { css } from 'nextia'
83
- import { useEffect } from 'react'
84
82
  import './style.css'
85
83
 
86
84
  export default function ${componentName} ({ className, style }) {
@@ -106,27 +104,26 @@ export default function ${componentName} ({ className, style }) {
106
104
  }
107
105
  }
108
106
 
109
- async function createContainer(name) {
107
+ async function createComponentFx(name) {
110
108
  const dirName = `./src/components/${name}`
109
+ const componentFxName = toPascalCase(name)
111
110
 
112
111
  try {
113
112
  await mkdir(dirName)
114
- const containerName = toPascalCase(name)
115
113
 
116
114
  // index.jsx
117
115
  writeFile(
118
116
  `${dirName}/index.jsx`,
119
117
  `import { css, useFx } from 'nextia'
120
- import { useEffect } from 'react'
121
118
  import functions from './functions'
122
119
  import './style.css'
123
120
 
124
- export default function ${containerName} ({ className, style }) {
121
+ export default function ${componentFxName} ({ className, style }) {
125
122
  const { state, fx } = useFx(functions)
126
123
 
127
124
  return (
128
- <article className={css('${containerName}', className, '')} style={style}>
129
- ${containerName}
125
+ <article className={css('${componentFxName}', className, '')} style={style}>
126
+ ${componentFxName}
130
127
  </article>
131
128
  )
132
129
  }
@@ -136,7 +133,7 @@ export default function ${containerName} ({ className, style }) {
136
133
  // style.css
137
134
  writeFile(
138
135
  `${dirName}/style.css`,
139
- `.${containerName} {
136
+ `.${componentFxName} {
140
137
  }
141
138
  `
142
139
  )
@@ -149,9 +146,9 @@ export default function ${containerName} ({ className, style }) {
149
146
  export default { initialState }
150
147
  `
151
148
  )
152
- console.info(`✔ Container "${name}" created at ${dirName}`)
149
+ console.info(`✔ ComponentFx "${name}" created at ${dirName}`)
153
150
  } catch (err) {
154
- console.error(`Failed to create container: ${err.message}`)
151
+ console.error(`Failed to create component:fx: ${err.message}`)
155
152
  }
156
153
  }
157
154
 
@@ -162,17 +159,17 @@ async function main() {
162
159
  switch (ARG1) {
163
160
  case 'page':
164
161
  if (ARG2) await createPage(ARG2)
165
- else console.warn('node --run nextia page <page-name>')
162
+ else console.warn('node --run page -- <page-name>')
166
163
  break
167
164
 
168
165
  case 'component':
169
166
  if (ARG2) await createComponent(ARG2)
170
- else console.warn('node --run nextia component <ComponentName>')
167
+ else console.warn('node --run component -- <ComponentName>')
171
168
  break
172
169
 
173
- case 'container':
174
- if (ARG2) await createContainer(ARG2)
175
- else console.warn('node --run nextia container <ContainerName>')
170
+ case 'component:fx':
171
+ if (ARG2) await createComponentFx(ARG2)
172
+ else console.warn('node --run component:fx -- <ComponentFxName>')
176
173
  break
177
174
  }
178
175
  }