@newlogic-digital/cli 1.4.0 → 1.4.1

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": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "newlogic-cli": "index.mjs",
@@ -4,6 +4,37 @@ import fse from 'fs-extra'
4
4
  import { join, resolve } from 'path'
5
5
  import { isAutoYes, normalizeEnum, normalizeYesNo } from './options.mjs'
6
6
 
7
+ function replaceInFile(path, searchValue, replaceValue) {
8
+ if (!fse.existsSync(path)) {
9
+ return
10
+ }
11
+
12
+ const content = fse.readFileSync(path, 'utf8')
13
+ fse.writeFileSync(path, content.replace(searchValue, replaceValue))
14
+ }
15
+
16
+ function updateBlankPackageJson(path) {
17
+ if (!fse.existsSync(path)) {
18
+ return
19
+ }
20
+
21
+ const packageJson = JSON.parse(fse.readFileSync(path, 'utf8'))
22
+ const originalDependencies = (packageJson.dependencies && typeof packageJson.dependencies === 'object')
23
+ ? packageJson.dependencies
24
+ : {}
25
+
26
+ if (packageJson.scripts && typeof packageJson.scripts === 'object') {
27
+ delete packageJson.scripts['build-emails']
28
+ }
29
+
30
+ packageJson.dependencies = Object.fromEntries(
31
+ ['@newlogic-digital/utils-js', 'winduum']
32
+ .flatMap(name => Object.hasOwn(originalDependencies, name) ? [[name, originalDependencies[name]]] : []),
33
+ )
34
+
35
+ fse.writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`)
36
+ }
37
+
7
38
  function prepareBlankInstall(projectPath) {
8
39
  [
9
40
  join(projectPath, 'src', 'template', 'emails'),
@@ -14,12 +45,9 @@ function prepareBlankInstall(projectPath) {
14
45
  join(projectPath, 'src', 'styles', 'tinymce.css'),
15
46
  ].forEach(path => fse.removeSync(path))
16
47
 
17
- const mainDataPath = join(projectPath, 'src', 'data', 'main.json')
18
-
19
- if (fse.existsSync(mainDataPath)) {
20
- const mainData = fse.readFileSync(mainDataPath, 'utf8').replace('"cookieConsent": true', '"cookieConsent": false')
21
- fse.writeFileSync(mainDataPath, mainData)
22
- }
48
+ replaceInFile(join(projectPath, 'src', 'data', 'main.json'), '"cookieConsent": true', '"cookieConsent": false')
49
+ replaceInFile(join(projectPath, 'src', 'templates', 'layouts', 'default.latte'), '<body data-controller="x-app invoke" data-naja-snippet-append>', '<body>')
50
+ updateBlankPackageJson(join(projectPath, 'package.json'))
23
51
 
24
52
  const iconsPath = join(projectPath, 'src', 'icons')
25
53
  fse.ensureDirSync(iconsPath)