@cyklang/cli 0.15.21 → 0.16.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/build/index.js +1 -1
- package/package.json +2 -2
- package/src/RunCommand.ts +2 -1
- package/src/TestCommand.ts +2 -1
- package/src/console.ts +48 -1
- package/src/index.ts +1 -1
- package/t37.xlsx +0 -0
- package/test/t36.xml +11 -0
- package/test/t37.xml +19 -0
package/build/index.js
CHANGED
|
@@ -182,7 +182,7 @@ class StopCommand extends commander_1.Command {
|
|
|
182
182
|
*/
|
|
183
183
|
const program = new commander_1.Command();
|
|
184
184
|
program.name('cyk').description('cyklang CLI')
|
|
185
|
-
.version('0.15.
|
|
185
|
+
.version('0.15.23');
|
|
186
186
|
program.addCommand(new StartCommand('start'));
|
|
187
187
|
program.addCommand(new StopCommand('stop'));
|
|
188
188
|
program.addCommand(new InstallCommand_1.InstallCommand('install'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyklang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "cyklang CLI",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cyklang/core": "^0.
|
|
22
|
+
"@cyklang/core": "^0.35.0",
|
|
23
23
|
"commander": "^9.4.0",
|
|
24
24
|
"dotenv": "^16.0.1",
|
|
25
25
|
"form-data": "^4.0.0",
|
package/src/RunCommand.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Structure, Script, XmlError, DBRemote, DBManager, ModuleInstruction, parseXML, MapData, loadLanguageModule } from "@cyklang/core"
|
|
2
2
|
import * as fs from "fs"
|
|
3
|
-
import { errorconsole, PrintInstructionType } from "./console"
|
|
3
|
+
import { errorconsole, PrintInstructionType, WriteFileInstructionType } from "./console"
|
|
4
4
|
import loglevel from 'loglevel'
|
|
5
5
|
import { NodeCrypto } from "./NodeCrypto"
|
|
6
6
|
import { Cmd } from "./Cmd"
|
|
@@ -60,6 +60,7 @@ export async function runFile(filename: string): Promise<void> {
|
|
|
60
60
|
const login = await dbRemote.signin(process.env.USER_NAME, undefined, process.env.USER_PASSWORD)
|
|
61
61
|
const dbManager = new DBManager(structure.scope, dbRemote)
|
|
62
62
|
await dbManager.initialize()
|
|
63
|
+
structure.scope.addInstructionType(new WriteFileInstructionType("write_file"))
|
|
63
64
|
|
|
64
65
|
await loadLanguageModule(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG])
|
|
65
66
|
|
package/src/TestCommand.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Structure, Script, XmlError, DBRemote, DBManager, MapData, ModuleInstruction, parseXML, loadLanguageModule } from "@cyklang/core"
|
|
2
2
|
import * as fs from "fs"
|
|
3
|
-
import { errorconsole, PrintInstructionType } from "./console"
|
|
3
|
+
import { errorconsole, PrintInstructionType, WriteFileInstructionType } from "./console"
|
|
4
4
|
import loglevel from 'loglevel'
|
|
5
5
|
import { NodeCrypto } from "./NodeCrypto"
|
|
6
6
|
import { Cmd } from "./Cmd"
|
|
@@ -64,6 +64,7 @@ async function testfile(filename: string): Promise<boolean> {
|
|
|
64
64
|
const dbManager = new DBManager(structure.scope, dbRemote)
|
|
65
65
|
await dbManager.initialize()
|
|
66
66
|
structure.scope.addInstructionType(new PrintInstructionType(logfilename))
|
|
67
|
+
structure.scope.addInstructionType(new WriteFileInstructionType("write_file"))
|
|
67
68
|
|
|
68
69
|
await loadLanguageModule(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG])
|
|
69
70
|
|
package/src/console.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XmlError } from '@cyklang/core'
|
|
1
|
+
import { BufferData, Jump, ObjectData, XmlError } from '@cyklang/core'
|
|
2
2
|
import * as fs from "fs"
|
|
3
3
|
import { Instruction, InstructionType, Tag } from '@cyklang/core'
|
|
4
4
|
import { Data, Scope } from '@cyklang/core'
|
|
@@ -96,3 +96,50 @@ class PrintInstruction extends Instruction {
|
|
|
96
96
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
export class WriteFileInstructionType extends InstructionType {
|
|
104
|
+
|
|
105
|
+
constructor(name: string) {
|
|
106
|
+
super(name)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async parseInstruction(tag: Tag, scope: Scope): Promise<Instruction> {
|
|
110
|
+
return new WriteFileInstruction(tag)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
class WriteFileInstruction extends Instruction {
|
|
119
|
+
|
|
120
|
+
constructor(tag: Tag) {
|
|
121
|
+
super(tag)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async execute(scope: Scope): Promise<Jump> {
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const objectDataType = scope.structure.objectDataType
|
|
128
|
+
const objParams = await objectDataType.parseData(this.tag, scope) as ObjectData
|
|
129
|
+
const pathname = objParams.variables.getString("pathname")
|
|
130
|
+
if (! pathname) throw `pathname parameter is missing`
|
|
131
|
+
const content = objParams.variables.getData("content") as BufferData
|
|
132
|
+
if (! content) throw `content parameter is missing`
|
|
133
|
+
if (! content.buffer) throw `content is empty`
|
|
134
|
+
|
|
135
|
+
fs.writeFileSync(pathname, content.buffer)
|
|
136
|
+
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
if (err instanceof XmlError) throw err
|
|
141
|
+
throw new XmlError(`${this.tagName}() error : ${err}`, this.tag)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -176,7 +176,7 @@ class StopCommand extends Command {
|
|
|
176
176
|
*/
|
|
177
177
|
const program = new Command()
|
|
178
178
|
program.name('cyk').description('cyklang CLI')
|
|
179
|
-
.version('0.
|
|
179
|
+
.version('0.16.0')
|
|
180
180
|
program.addCommand(new StartCommand('start'))
|
|
181
181
|
program.addCommand(new StopCommand('stop'))
|
|
182
182
|
program.addCommand(new InstallCommand('install'))
|
package/t37.xlsx
ADDED
|
Binary file
|
package/test/t36.xml
CHANGED
|
@@ -126,4 +126,15 @@
|
|
|
126
126
|
</call>
|
|
127
127
|
<print>"APRES add_language_map"</print>
|
|
128
128
|
<print>format("NIR")</print>
|
|
129
|
+
|
|
130
|
+
<print>format_date("2024-02-15")</print>
|
|
131
|
+
|
|
132
|
+
<print>format_month("2024-02-15")</print>
|
|
133
|
+
|
|
134
|
+
<print>format_datetime("2024-02-15 14:00")</print>
|
|
135
|
+
|
|
136
|
+
<print>format("fixed(0, 2) = {0}", fixed(0,2))</print>
|
|
137
|
+
<buffer name="input">buffer("rue de la ferté")</buffer>
|
|
138
|
+
<buffer name="output">convert_text_encoding(input,"utf-8","latin1")</buffer>
|
|
139
|
+
<print>format("input = {0}, output = {1}",string(input),string(output))</print>
|
|
129
140
|
</module>
|
package/test/t37.xml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml-model href="https://www.cyklang.net/schema/cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<object name="list">
|
|
4
|
+
<object>
|
|
5
|
+
<string name="Nom">"CHANE"</string>
|
|
6
|
+
<string name="Prénom">"Phil"</string>
|
|
7
|
+
</object>
|
|
8
|
+
<object>
|
|
9
|
+
<string name="Nom">"LAU"</string>
|
|
10
|
+
<string name="Prénom">"érika"</string>
|
|
11
|
+
</object>
|
|
12
|
+
</object>
|
|
13
|
+
|
|
14
|
+
<write_file>
|
|
15
|
+
<string name="pathname">"t37.xlsx"</string>
|
|
16
|
+
<buffer name="content">xlsx(list)</buffer>
|
|
17
|
+
</write_file>
|
|
18
|
+
|
|
19
|
+
</module>
|