@keload/node-red-dxp 1.25.0 → 1.26.0
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/dist/cli/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
8
8
|
`),n=r-1;e=[...t.slice(0,n),`... (content truncated to fit terminal)`].join(`
|
|
9
9
|
`)}return this.#c.write(e),this.#e=this.#b(e,t),this}start(e){if(e&&(this.text=e),this.#f)return this;if(!this.#d){let e=` `.repeat(this.#p)+this.#v(this.#h,` `)+(this.text?`- ${this.text}`:``)+this.#y(this.#g,` `);return e.trim()!==``&&this.#c.write(e+`
|
|
10
10
|
`),this}return this.isSpinning?this:(this.#o.hideCursor&&pt.hide(this.#c),this.#o.discardStdin&&l.default.stdin.isTTY&&(this.#t=!0,jn.start()),this.render(),this.#l=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#l),this.#l=void 0,this.#r=0,this.#d&&(this.clear(),this.#o.hideCursor&&pt.show(this.#c)),this.#o.discardStdin&&l.default.stdin.isTTY&&this.#t&&(jn.stop(),this.#t=!1),this}succeed(e){return this.stopAndPersist({symbol:cn,text:e})}fail(e){return this.stopAndPersist({symbol:un,text:e})}warn(e){return this.stopAndPersist({symbol:ln,text:e})}info(e){return this.stopAndPersist({symbol:sn,text:e})}stopAndPersist(e={}){if(this.#f)return this;let t=e.prefixText??this.#h,n=this.#v(t,` `),r=e.symbol??` `,i=e.text??this.text,a=typeof i==`string`?(r?` `:``)+i:``,o=e.suffixText??this.#g,s=this.#y(o,` `),c=n+r+a+s+`
|
|
11
|
-
`;return this.stop(),this.#c.write(c),this}};function Nn(e){return new Mn(e)}var Pn=`1.
|
|
11
|
+
`;return this.stop(),this.#c.write(c),this}};function Nn(e){return new Mn(e)}var Pn=`1.25.0`;function Fn(e){return Object.prototype.toString.call(e).slice(8,-1)}function W(e){if(Fn(e)!==`Object`)return!1;let t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function In(e){return Fn(e)===`Symbol`}function Ln(e,t,n,r){let i={}.propertyIsEnumerable.call(r,t)?`enumerable`:`nonenumerable`;i===`enumerable`&&(e[t]=n),i===`nonenumerable`&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function Rn(e,t,n){if(!W(t))return t;let r={};if(W(e)){let n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);r=[...n,...i].reduce((n,r)=>{if(r===`__proto__`)return n;let i=e[r];return(!In(r)&&!Object.getOwnPropertyNames(t).includes(r)||In(r)&&!Object.getOwnPropertySymbols(t).includes(r))&&Ln(n,r,i,e),n},{})}let i=Object.getOwnPropertyNames(t),a=Object.getOwnPropertySymbols(t);return[...i,...a].reduce((r,i)=>{if(i===`__proto__`)return r;let a=t[i],o=W(e)?e[i]:void 0;return o!==void 0&&W(a)&&(a=Rn(o,a,n)),Ln(r,i,n?n(o,a,i):a,t),r},r)}function zn(e,...t){return t.reduce((e,t)=>Rn(e,t),e)}const Bn={builder:{outputDir:`dist`,esbuildControllerOptions:{includeInBundle:[]},tailwind:{forcedClassesInclusion:[]},editor:{webComponents:{formRow:!1}}},watcher:{nodeRed:{enabled:!0,path:`~/.node-red`,url:`http://localhost:1880`}}},G={libCacheDir:`.node-red-dxp`,srcDir:`src`,nodesDirName:`nodes`,localesDirName:`locales`,globalStylesName:`styles`,nodes:{controllerName:`controller`,editor:{dirName:`editor`,htmlName:`index`,stylesName:`styles`,tsName:`index`}}},Vn=`node-red-dxp`,Hn=e=>e.replace(`@`,``).replace(`/`,`-`);function Un(){let e=(0,ee.cosmiconfigSync)(`node-red-dxp`);try{let t=e.search();return zn(Bn,t?t.config:{})}catch(e){throw console.error(`Error while loading configuration`,e),e}}const K=Un(),q=process.cwd(),Wn=JSON.parse((0,m.readFileSync)(`${q}/package.json`,`utf-8`)),J=`${q}/${G.srcDir}`,Gn=`${q}/resources`,Kn=`${q}/resources`,Y=`${J}/${G.nodesDirName}`,qn=`${q}/${G.libCacheDir}`,Jn=`${h.default.resolve(__dirname,`..`)}`,Yn=Hn(Wn.name);function Xn(e=[]){return e.map(e=>{let t=e.path,n=`${t}/${G.nodes.editor.dirName}`,r=t.replace(q,``).slice(1),i=`${r}/${G.nodes.editor.dirName}`,a=(0,g.globSync)(`${n}/${G.nodes.editor.stylesName}.scss`),o=(0,g.globSync)(`${t}/docs.mdx`),s=(0,g.globSync)(`${t}/docs.md`),c=(0,_.dash)(e.name);return{fullEditorPath:n,fullPath:t,name:e.name,pascalName:(0,_.pascal)(e.name),dashName:c,relativeEditorPath:i,relativePath:r,nodeIdentifier:`${Yn}-${c}`,fullControllerPath:`${t}/${G.nodes.controllerName}.ts`,editor:{tsPath:`${n}/${G.nodes.editor.tsName}.ts`,htmlPath:`${n}/${G.nodes.editor.htmlName}.html`,pugPath:`${n}/${G.nodes.editor.htmlName}.pug`,scssFiles:a},doc:{mdxFiles:o,mdFiles:s}}})}function Zn(){let e=(0,g.globSync)(`${Y}/**/*`,{onlyDirectories:!0,deep:1,objectMode:!0}),t=Xn(e),n=t.map(e=>e.name);return{currentDir:q,pathSrcDir:J,pathSrcNodesDir:Y,pathResourcesDir:Gn,additionalResourcesDir:Kn,pathDist:`${q}/${K.builder.outputDir}`,currentPackagedDistPath:Jn,cacheDirFiles:{controllerIndex:`${qn}/controller-index.ts`,editorIndex:`${qn}/editor-index.ts`},pathLibCacheDir:qn,packageName:Wn.name,packageNameSlug:Yn,config:K,resolvedSrcPathsScss:(0,g.globSync)(`${J}/${G.globalStylesName}.scss`,{ignore:[`${Y}/**/*.scss`]}),resolvedNodesPaths:e.map(e=>e.path),resolvedSrcLocalesPaths:(0,g.globSync)(`${J}/${G.localesDirName}/*.json`),redServerPath:(0,g.globSync)(`${J}/red-server.ts`),listNodesFull:t,listNodesFullNames:n}}const X=Zn(),Qn=`${h.default.resolve(__dirname,`..`)}`;function Z(e){m.default.existsSync(e)||m.default.mkdirSync(e,{recursive:!0})}async function Q(e,t){try{await p.default.writeFile(e,t)}catch(e){console.error(`Error writing controller index:`,e)}}async function $n(e){for(let t of e)try{let e=h.default.resolve(t),n=await p.default.stat(e).catch(()=>null);n!=null&&n.isDirectory()&&await p.default.rm(e,{recursive:!0,force:!0})}catch(e){console.error(`Error cleaning path (${t}): ${e}`)}}const er={name:`add-credentials-export`,setup(e){e.onLoad({filter:/controller\.ts$/},async e=>{let t=await p.default.readFile(e.path,`utf8`);return/export\s+const\s+credentials\s*=/.test(t)?{contents:t,loader:`ts`}:{contents:`${t}\nexport const credentials = {};`,loader:`ts`}})}},tr=`${X.currentDir}/package.json`;var nr=class{constructor(e){this.params={minify:!1,...e}}async getControllerIndexContent(){return`
|
|
12
12
|
import type { NodeAPI } from 'node-red';
|
|
13
13
|
${X.listNodesFull.map(e=>`// @ts-ignore\nimport ${e.pascalName}, {credentials as cred${e.pascalName}} from '${e.fullControllerPath}';`).join(`
|
|
14
14
|
`)}
|
|
@@ -31,17 +31,18 @@ mixin commonLabel(params)
|
|
|
31
31
|
- var capitalizedLabel = capitalizeFirst(params.label || '')
|
|
32
32
|
label(for=params.id)
|
|
33
33
|
+iconFontAwesome(params.icon)
|
|
34
|
-
span(data-i18n
|
|
34
|
+
span(data-i18n=`${params.i18nKey};[title]${params.i18nKey}` title=capitalizedLabel)= capitalizedLabel
|
|
35
35
|
|
|
36
36
|
mixin dxpFormRowInputText(params)
|
|
37
37
|
- var inputId = generateInputId(params.id, params.isConfig)
|
|
38
|
+
- var i18nKey = params.i18nKey || params.id
|
|
38
39
|
.dxp-template-form-row(class=params.rowClasses)
|
|
39
|
-
+commonLabel({label: params.label, icon: params.icon, id: inputId})
|
|
40
|
+
+commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
|
|
40
41
|
.content
|
|
41
42
|
input(
|
|
42
43
|
type="text"
|
|
43
44
|
id=inputId
|
|
44
|
-
data-i18n=`[placeholder]${params.
|
|
45
|
+
data-i18n=`[placeholder]${params.id}-placeholder`
|
|
45
46
|
placeholder=params.placeholder || ''
|
|
46
47
|
)&attributes(attributes)
|
|
47
48
|
if params.isTyped
|
|
@@ -51,8 +52,9 @@ mixin dxpFormRowInputText(params)
|
|
|
51
52
|
|
|
52
53
|
mixin dxpFormRowCheckbox(params)
|
|
53
54
|
- var inputId = generateInputId(params.id, params.isConfig)
|
|
55
|
+
- var i18nKey = params.i18nKey || params.id
|
|
54
56
|
.dxp-template-form-row(class=params.rowClasses)
|
|
55
|
-
+commonLabel({label: params.label, icon: params.icon, id: inputId})
|
|
57
|
+
+commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
|
|
56
58
|
.content
|
|
57
59
|
.checkbox
|
|
58
60
|
input(type="checkbox" id=inputId)&attributes(attributes)
|
|
@@ -63,8 +65,9 @@ mixin dxpFormRowCheckbox(params)
|
|
|
63
65
|
|
|
64
66
|
mixin dxpFormRowSelect(params)
|
|
65
67
|
- var inputId = generateInputId(params.id, params.isConfig)
|
|
68
|
+
- var i18nKey = params.i18nKey || params.id
|
|
66
69
|
.dxp-template-form-row(class=params.rowClasses)
|
|
67
|
-
+commonLabel({label: params.label, icon: params.icon, id: inputId})
|
|
70
|
+
+commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
|
|
68
71
|
.content
|
|
69
72
|
select(id=inputId)&attributes(attributes)
|
|
70
73
|
if block
|
|
@@ -72,8 +75,9 @@ mixin dxpFormRowSelect(params)
|
|
|
72
75
|
|
|
73
76
|
mixin dxpFormRowSelectConfigNode(params)
|
|
74
77
|
- var inputId = generateInputId(params.id, params.isConfig)
|
|
78
|
+
- var i18nKey = params.i18nKey || params.id
|
|
75
79
|
.dxp-template-form-row(class=params.rowClasses)
|
|
76
|
-
+commonLabel({label: params.label, icon: params.icon, id: inputId})
|
|
80
|
+
+commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
|
|
77
81
|
.content.force-w-full
|
|
78
82
|
select(id=inputId)&attributes(attributes)
|
|
79
83
|
if block
|
|
@@ -87,8 +91,9 @@ mixin dxpFormTitleSeparator(label)
|
|
|
87
91
|
div.flex-1.border-t.border-gray-300
|
|
88
92
|
|
|
89
93
|
mixin dxpHint(params)
|
|
90
|
-
- var
|
|
91
|
-
- var
|
|
94
|
+
- var params = params ?? {}
|
|
95
|
+
- var classState = params?.state ? 'hint-' + params.state : ''
|
|
96
|
+
- var width = params?.fullWidth ? '' : 'max-w-[350px]'
|
|
92
97
|
.hint(class=classState + ' ' + width)
|
|
93
98
|
+iconFontAwesome(params.icon)(class="mr-1")
|
|
94
99
|
if block
|