@cyklang/cli 0.16.1 → 0.17.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/build/RunCommand.js +1 -0
- package/build/TestCommand.js +1 -0
- package/build/console.d.ts +9 -2
- package/build/console.js +29 -1
- package/package.json +2 -2
- package/src/RunCommand.ts +2 -1
- package/src/TestCommand.ts +3 -1
- package/src/console.ts +27 -1
- package/src/index.ts +1 -1
- package/t37.xlsx +0 -0
- package/test/t37.xml +19 -2
package/build/RunCommand.js
CHANGED
|
@@ -86,6 +86,7 @@ async function runFile(filename) {
|
|
|
86
86
|
const dbManager = new core_1.DBManager(structure.scope, dbRemote);
|
|
87
87
|
await dbManager.initialize();
|
|
88
88
|
structure.scope.addInstructionType(new console_1.WriteFileInstructionType("write_file"));
|
|
89
|
+
structure.scope.addFunction('read_file', console_1.read_file);
|
|
89
90
|
await (0, core_1.loadLanguageModule)(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG]);
|
|
90
91
|
let script = new core_1.Script(structure.scope, xmlfilename, xml.toString(), dbManager);
|
|
91
92
|
await script.parseInstructions();
|
package/build/TestCommand.js
CHANGED
|
@@ -87,6 +87,7 @@ async function testfile(filename) {
|
|
|
87
87
|
await dbManager.initialize();
|
|
88
88
|
structure.scope.addInstructionType(new console_1.PrintInstructionType(logfilename));
|
|
89
89
|
structure.scope.addInstructionType(new console_1.WriteFileInstructionType("write_file"));
|
|
90
|
+
structure.scope.addFunction('read_file', console_1.read_file);
|
|
90
91
|
await (0, core_1.loadLanguageModule)(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG]);
|
|
91
92
|
let script = new core_1.Script(structure.scope, xmlfilename, xml.toString(), dbManager);
|
|
92
93
|
await script.parseInstructions();
|
package/build/console.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { XmlError } from '@cyklang/core';
|
|
1
|
+
import { Variables, XmlError } from '@cyklang/core';
|
|
2
2
|
import { Instruction, InstructionType, Tag } from '@cyklang/core';
|
|
3
|
-
import { Scope } from '@cyklang/core';
|
|
3
|
+
import { Data, Scope } from '@cyklang/core';
|
|
4
4
|
export declare function errorconsole(xmlError: XmlError): void;
|
|
5
5
|
export declare class InputInstructionType extends InstructionType {
|
|
6
6
|
constructor();
|
|
@@ -11,6 +11,13 @@ export declare class PrintInstructionType extends InstructionType {
|
|
|
11
11
|
constructor(logfilename: string);
|
|
12
12
|
parseInstruction(tag: Tag, scope: Scope): Promise<Instruction>;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param params
|
|
17
|
+
* @param callerScope
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function read_file(params: Variables, callerScope: Scope): Promise<Data | undefined>;
|
|
14
21
|
/**
|
|
15
22
|
*
|
|
16
23
|
*/
|
package/build/console.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.WriteFileInstructionType = exports.PrintInstructionType = exports.InputInstructionType = exports.errorconsole = void 0;
|
|
26
|
+
exports.WriteFileInstructionType = exports.read_file = exports.PrintInstructionType = exports.InputInstructionType = exports.errorconsole = void 0;
|
|
27
27
|
const core_1 = require("@cyklang/core");
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const core_2 = require("@cyklang/core");
|
|
@@ -112,6 +112,34 @@ class PrintInstruction extends core_2.Instruction {
|
|
|
112
112
|
dump() {
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param params
|
|
118
|
+
* @param callerScope
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
async function read_file(params, callerScope) {
|
|
122
|
+
try {
|
|
123
|
+
let result = callerScope.structure.undefinedData;
|
|
124
|
+
if (params.length() === 0)
|
|
125
|
+
throw 'needs filename to read';
|
|
126
|
+
const param1 = params.at(0);
|
|
127
|
+
if (param1 === undefined)
|
|
128
|
+
throw 'filename is undefined';
|
|
129
|
+
const pathname = param1.variable.getString();
|
|
130
|
+
if (pathname === undefined)
|
|
131
|
+
throw 'pathname is undefined';
|
|
132
|
+
const buffer = fs.readFileSync(pathname);
|
|
133
|
+
const bufferData = new core_1.BufferData(callerScope.structure.bufferDataType);
|
|
134
|
+
bufferData.buffer = buffer;
|
|
135
|
+
result = bufferData;
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
throw `read_file() error : ${err}`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.read_file = read_file;
|
|
115
143
|
/**
|
|
116
144
|
*
|
|
117
145
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyklang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
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.36.1",
|
|
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, WriteFileInstructionType } from "./console"
|
|
3
|
+
import { errorconsole, PrintInstructionType, read_file, WriteFileInstructionType } from "./console"
|
|
4
4
|
import loglevel from 'loglevel'
|
|
5
5
|
import { NodeCrypto } from "./NodeCrypto"
|
|
6
6
|
import { Cmd } from "./Cmd"
|
|
@@ -61,6 +61,7 @@ export async function runFile(filename: string): Promise<void> {
|
|
|
61
61
|
const dbManager = new DBManager(structure.scope, dbRemote)
|
|
62
62
|
await dbManager.initialize()
|
|
63
63
|
structure.scope.addInstructionType(new WriteFileInstructionType("write_file"))
|
|
64
|
+
structure.scope.addFunction('read_file', read_file)
|
|
64
65
|
|
|
65
66
|
await loadLanguageModule(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG])
|
|
66
67
|
|
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, WriteFileInstructionType } from "./console"
|
|
3
|
+
import { errorconsole, PrintInstructionType, read_file, WriteFileInstructionType } from "./console"
|
|
4
4
|
import loglevel from 'loglevel'
|
|
5
5
|
import { NodeCrypto } from "./NodeCrypto"
|
|
6
6
|
import { Cmd } from "./Cmd"
|
|
@@ -65,6 +65,8 @@ async function testfile(filename: string): Promise<boolean> {
|
|
|
65
65
|
await dbManager.initialize()
|
|
66
66
|
structure.scope.addInstructionType(new PrintInstructionType(logfilename))
|
|
67
67
|
structure.scope.addInstructionType(new WriteFileInstructionType("write_file"))
|
|
68
|
+
structure.scope.addFunction('read_file', read_file)
|
|
69
|
+
|
|
68
70
|
|
|
69
71
|
await loadLanguageModule(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG])
|
|
70
72
|
|
package/src/console.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BufferData, Jump, ObjectData, XmlError } from '@cyklang/core'
|
|
1
|
+
import { BufferData, Jump, ObjectData, Variables, 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'
|
|
@@ -97,6 +97,32 @@ class PrintInstruction extends Instruction {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param params
|
|
103
|
+
* @param callerScope
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
export async function read_file(params: Variables, callerScope: Scope): Promise<Data | undefined> {
|
|
107
|
+
try {
|
|
108
|
+
let result = callerScope.structure.undefinedData
|
|
109
|
+
if (params.length() === 0) throw 'needs filename to read'
|
|
110
|
+
const param1 = params.at(0)
|
|
111
|
+
if (param1 === undefined) throw 'filename is undefined'
|
|
112
|
+
const pathname = param1.variable.getString()
|
|
113
|
+
if (pathname === undefined) throw 'pathname is undefined'
|
|
114
|
+
const buffer = fs.readFileSync(pathname)
|
|
115
|
+
const bufferData = new BufferData(callerScope.structure.bufferDataType)
|
|
116
|
+
bufferData.buffer = buffer
|
|
117
|
+
result = bufferData
|
|
118
|
+
|
|
119
|
+
return result
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
throw `read_file() error : ${err}`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
100
126
|
/**
|
|
101
127
|
*
|
|
102
128
|
*/
|
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.17.1')
|
|
180
180
|
program.addCommand(new StartCommand('start'))
|
|
181
181
|
program.addCommand(new StopCommand('stop'))
|
|
182
182
|
program.addCommand(new InstallCommand('install'))
|
package/t37.xlsx
CHANGED
|
Binary file
|
package/test/t37.xml
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
<module>
|
|
3
3
|
<object name="list">
|
|
4
4
|
<object>
|
|
5
|
+
<number name="Id">1</number>
|
|
5
6
|
<string name="Nom">"CHANE"</string>
|
|
6
|
-
<string name="
|
|
7
|
+
<string name="Prenom">"Phil"</string>
|
|
8
|
+
<number name="Salaire">15250.34</number>
|
|
9
|
+
<string name="Commentaire">"Hello"</string>
|
|
7
10
|
</object>
|
|
8
11
|
<object>
|
|
12
|
+
<number name="Id">2</number>
|
|
9
13
|
<string name="Nom">"LAU"</string>
|
|
10
|
-
<string name="
|
|
14
|
+
<string name="Prenom">"érika"</string>
|
|
15
|
+
<number name="Salaire"></number>
|
|
11
16
|
</object>
|
|
12
17
|
</object>
|
|
13
18
|
|
|
@@ -16,4 +21,16 @@
|
|
|
16
21
|
<buffer name="content">xlsx(list)</buffer>
|
|
17
22
|
</write_file>
|
|
18
23
|
|
|
24
|
+
|
|
25
|
+
<buffer name="bExcel">read_file("t37.xlsx")</buffer>
|
|
26
|
+
<type name="columns">
|
|
27
|
+
<string name="Nom"/>
|
|
28
|
+
<string name="Prenom"/>
|
|
29
|
+
<number name="Salaire"/>
|
|
30
|
+
</type>
|
|
31
|
+
|
|
32
|
+
<object name="result">parsexlsx(bExcel, columns)</object>
|
|
33
|
+
|
|
34
|
+
<print>format("result = {0}", result)</print>
|
|
35
|
+
|
|
19
36
|
</module>
|