@newlogic-digital/cli 0.0.12 → 0.0.15
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newlogic-digital/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"main": "index.mjs",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newlogic-cli": "index.mjs",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"prompts": "^2.4.2",
|
|
15
15
|
"fs-extra": "^10.1.0",
|
|
16
16
|
"picocolors": "^1.0.0",
|
|
17
|
-
"fast-glob": "^3.2.11"
|
|
17
|
+
"fast-glob": "^3.2.11",
|
|
18
|
+
"dedent": "^0.7.0"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"eslint": "^8.23.0",
|
|
@@ -2,9 +2,9 @@ import FastGlob from 'fast-glob'
|
|
|
2
2
|
import { join, relative, extname } from 'path'
|
|
3
3
|
import fs from 'fs'
|
|
4
4
|
import fse from 'fs-extra'
|
|
5
|
-
import { stripIndent } from '../../utils.mjs'
|
|
6
5
|
import pc from 'picocolors'
|
|
7
6
|
import lodash from 'lodash'
|
|
7
|
+
import dedent from 'dedent'
|
|
8
8
|
|
|
9
9
|
let sectionsCount = 0
|
|
10
10
|
let sectionsFactoryCount = 0
|
|
@@ -107,43 +107,53 @@ export default function prepare(options) {
|
|
|
107
107
|
|
|
108
108
|
Object.keys(controls).forEach(control => {
|
|
109
109
|
if (control !== 'src') {
|
|
110
|
-
const type = typeof controls[control]
|
|
110
|
+
const type = typeof controls[control]
|
|
111
111
|
const value = typeof controls[control] === 'object' ? JSON.stringify(controls[control]) : controls[control]
|
|
112
112
|
|
|
113
|
+
let phpType = type
|
|
114
|
+
|
|
115
|
+
if (type === 'object' && Array.isArray(controls[control])) {
|
|
116
|
+
phpType = 'array'
|
|
117
|
+
} else if (type === 'boolean') {
|
|
118
|
+
phpType = 'bool'
|
|
119
|
+
} else if (type === 'number') {
|
|
120
|
+
phpType = 'int'
|
|
121
|
+
}
|
|
122
|
+
|
|
113
123
|
annotations.push(`
|
|
114
124
|
/**
|
|
115
125
|
* @field ${getField(control, type)}
|
|
116
126
|
* @title ${getTitle(control)}
|
|
117
127
|
* @value ${value}
|
|
118
128
|
*/
|
|
119
|
-
public ${
|
|
129
|
+
public ${phpType} $${control}${type === 'string' ? " = '" + value + "'" : ''};
|
|
120
130
|
`)
|
|
121
131
|
|
|
122
132
|
if (type === 'object') {
|
|
123
133
|
objects.push(`
|
|
124
|
-
$this->${control} = json_decode('${value}',
|
|
134
|
+
$this->${control} = json_decode('${value}', false);
|
|
125
135
|
`)
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
})
|
|
129
139
|
|
|
130
140
|
if (annotations.length > 0) {
|
|
131
|
-
annotations = annotations.map(item => item).join(
|
|
141
|
+
annotations = annotations.map(item => item).join('')
|
|
132
142
|
} else {
|
|
133
|
-
annotations =
|
|
143
|
+
annotations = ''
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
if (objects.length > 0) {
|
|
137
|
-
objects = objects.map(item => item).join(
|
|
147
|
+
objects = objects.map(item => item).join('')
|
|
138
148
|
} else {
|
|
139
|
-
objects =
|
|
149
|
+
objects = ''
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
fs.writeFileSync(join(options.path.app.sections, `${name}.php`),
|
|
143
|
-
|
|
153
|
+
dedent`
|
|
144
154
|
<?php
|
|
145
155
|
|
|
146
|
-
namespace App
|
|
156
|
+
namespace App\Sections;
|
|
147
157
|
|
|
148
158
|
class ${name} extends BaseSection
|
|
149
159
|
{
|
|
@@ -154,7 +164,7 @@ export default function prepare(options) {
|
|
|
154
164
|
$this->getTemplate()->render(TEMPLATES_DIR . '/${path}');
|
|
155
165
|
}
|
|
156
166
|
}
|
|
157
|
-
`
|
|
167
|
+
`
|
|
158
168
|
)
|
|
159
169
|
|
|
160
170
|
sectionsCount += 1
|
|
@@ -165,18 +175,18 @@ export default function prepare(options) {
|
|
|
165
175
|
if (!name.match(/(Ui)/)) {
|
|
166
176
|
if (!fs.existsSync(join(options.path.app.sectionsFactory, `${name}Factory.php`)) || force) {
|
|
167
177
|
fs.writeFileSync(join(options.path.app.sectionsFactory, `${name}Factory.php`),
|
|
168
|
-
|
|
178
|
+
dedent`
|
|
169
179
|
<?php
|
|
170
180
|
|
|
171
|
-
namespace App
|
|
181
|
+
namespace App\Sections\Factory;
|
|
172
182
|
|
|
173
|
-
use App\\Sections
|
|
183
|
+
use ${'App\\Sections\\'}${name};
|
|
174
184
|
|
|
175
185
|
interface ${name}Factory
|
|
176
186
|
{
|
|
177
187
|
public function create(): ${name};
|
|
178
188
|
}
|
|
179
|
-
`
|
|
189
|
+
`
|
|
180
190
|
)
|
|
181
191
|
|
|
182
192
|
sectionsFactoryCount += 1
|
|
@@ -218,17 +228,16 @@ export default function prepare(options) {
|
|
|
218
228
|
|
|
219
229
|
sections.forEach((section) => {
|
|
220
230
|
if (section.src) {
|
|
221
|
-
if (typeof sectionsUnsorted[section.src] ===
|
|
231
|
+
if (typeof sectionsUnsorted[section.src] === 'undefined') {
|
|
222
232
|
sectionsUnsorted[section.src] = []
|
|
223
|
-
sectionsUnsorted[section.src].push(section)
|
|
233
|
+
sectionsUnsorted[section.src].push(section)
|
|
224
234
|
} else {
|
|
225
|
-
sectionsUnsorted[section.src].push(section)
|
|
235
|
+
sectionsUnsorted[section.src].push(section)
|
|
226
236
|
}
|
|
227
237
|
}
|
|
228
238
|
})
|
|
229
239
|
})
|
|
230
240
|
|
|
231
|
-
|
|
232
241
|
Object.keys(sectionsUnsorted).forEach(key => {
|
|
233
242
|
const sortedSection = {}
|
|
234
243
|
|
|
@@ -9,7 +9,7 @@ import prompts from 'prompts'
|
|
|
9
9
|
const tempDir = join(os.tmpdir(), 'newlogic-cms-web')
|
|
10
10
|
|
|
11
11
|
async function move(path, options = {}) {
|
|
12
|
-
await fse.move(join(tempDir, path), resolve(process.cwd(), path), options).catch(err => console.log(`${pc.red(err)} - ${path}`
|
|
12
|
+
await fse.move(join(tempDir, path), resolve(process.cwd(), path), options).catch(err => console.log(`${pc.red(err)} - ${path}`))
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function clone(path, { variant, branch }) {
|
|
@@ -54,7 +54,7 @@ async function prepare() {
|
|
|
54
54
|
])
|
|
55
55
|
|
|
56
56
|
if (install === 'yes') {
|
|
57
|
-
execSync(
|
|
57
|
+
execSync('newlogic cms prepare')
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -87,6 +87,7 @@ export default async function cms(name, { variant, branch }) {
|
|
|
87
87
|
await move('docker-compose.yml')
|
|
88
88
|
await move('phpstan.neon')
|
|
89
89
|
await move('pint.json')
|
|
90
|
+
await fse.move(join(tempDir, '.gitlab-ci.prod.yml'), resolve(process.cwd(), '.gitlab-ci.yml'), { overwrite: true }).catch(err => console.log(`${pc.red(err)} - .gitlab-ci.yml`))
|
|
90
91
|
|
|
91
92
|
fse.removeSync(tempDir)
|
|
92
93
|
|