@cyklang/cli 0.16.0 → 0.16.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.
@@ -85,6 +85,7 @@ async function runFile(filename) {
85
85
  const login = await dbRemote.signin(process.env.USER_NAME, undefined, process.env.USER_PASSWORD);
86
86
  const dbManager = new core_1.DBManager(structure.scope, dbRemote);
87
87
  await dbManager.initialize();
88
+ structure.scope.addInstructionType(new console_1.WriteFileInstructionType("write_file"));
88
89
  await (0, core_1.loadLanguageModule)(structure.scope, dbManager, '', [login.content.user_lang, process.env.LANG]);
89
90
  let script = new core_1.Script(structure.scope, xmlfilename, xml.toString(), dbManager);
90
91
  await script.parseInstructions();
@@ -86,6 +86,7 @@ async function testfile(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.PrintInstructionType(logfilename));
89
+ structure.scope.addInstructionType(new console_1.WriteFileInstructionType("write_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();
@@ -11,3 +11,10 @@ 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
+ */
17
+ export declare class WriteFileInstructionType extends InstructionType {
18
+ constructor(name: string);
19
+ parseInstruction(tag: Tag, scope: Scope): Promise<Instruction>;
20
+ }
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.PrintInstructionType = exports.InputInstructionType = exports.errorconsole = void 0;
26
+ exports.WriteFileInstructionType = 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,3 +112,44 @@ class PrintInstruction extends core_2.Instruction {
112
112
  dump() {
113
113
  }
114
114
  }
115
+ /**
116
+ *
117
+ */
118
+ class WriteFileInstructionType extends core_2.InstructionType {
119
+ constructor(name) {
120
+ super(name);
121
+ }
122
+ async parseInstruction(tag, scope) {
123
+ return new WriteFileInstruction(tag);
124
+ }
125
+ }
126
+ exports.WriteFileInstructionType = WriteFileInstructionType;
127
+ /**
128
+ *
129
+ */
130
+ class WriteFileInstruction extends core_2.Instruction {
131
+ constructor(tag) {
132
+ super(tag);
133
+ }
134
+ async execute(scope) {
135
+ try {
136
+ const objectDataType = scope.structure.objectDataType;
137
+ const objParams = await objectDataType.parseData(this.tag, scope);
138
+ const pathname = objParams.variables.getString("pathname");
139
+ if (!pathname)
140
+ throw `pathname parameter is missing`;
141
+ const content = objParams.variables.getData("content");
142
+ if (!content)
143
+ throw `content parameter is missing`;
144
+ if (!content.buffer)
145
+ throw `content is empty`;
146
+ fs.writeFileSync(pathname, content.buffer);
147
+ return;
148
+ }
149
+ catch (err) {
150
+ if (err instanceof core_1.XmlError)
151
+ throw err;
152
+ throw new core_1.XmlError(`${this.tagName}() error : ${err}`, this.tag);
153
+ }
154
+ }
155
+ }
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.23');
185
+ .version('0.16.1');
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.16.0",
3
+ "version": "0.16.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.35.0",
22
+ "@cyklang/core": "^0.35.1",
23
23
  "commander": "^9.4.0",
24
24
  "dotenv": "^16.0.1",
25
25
  "form-data": "^4.0.0",
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.16.0')
179
+ .version('0.16.1')
180
180
  program.addCommand(new StartCommand('start'))
181
181
  program.addCommand(new StopCommand('stop'))
182
182
  program.addCommand(new InstallCommand('install'))