@cyklang/cli
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -27,3 +27,3 @@ "use strict"; | ||
throw 'DBREMOTE_URL undefined'; | ||
logger.debug('Cmd.DBREMOTE_URL ' + process.env.DBREMOTE_URL); | ||
logger.info('Cyk server: ' + process.env.DBREMOTE_URL); | ||
const nodeCrypto = new NodeCrypto_1.NodeCrypto(); | ||
@@ -30,0 +30,0 @@ this.dbRemote = new core_1.DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto); |
@@ -15,3 +15,3 @@ #!/usr/bin/env node | ||
const RunCommand_1 = require("./RunCommand"); | ||
const InitCommand_1 = require("./InitCommand"); | ||
const InstallCommand_1 = require("./InstallCommand"); | ||
const AssetCommand_1 = require("./AssetCommand"); | ||
@@ -24,3 +24,4 @@ const OpenCommand_1 = require("./OpenCommand"); | ||
.version('0.2'); | ||
program.addCommand(new InitCommand_1.InitCommand('init')); | ||
program.addCommand(new InstallCommand_1.InstallCommand('install')); | ||
program.addCommand(new InstallCommand_1.InstallCommand('i')); | ||
program.addCommand(new AssetCommand_1.AssetCommand('asset', 'manage assets')); | ||
@@ -37,4 +38,6 @@ program.addCommand(new AssetCommand_1.AssetCommand('a', 'manage assets')); | ||
program.addCommand(new TestCommand_1.TestCommand()); | ||
program.addCommand(new RunCommand_1.RunCommand()); | ||
program.addCommand(new OpenCommand_1.OpenCommand()); | ||
program.addCommand(new RunCommand_1.RunCommand('run')); | ||
program.addCommand(new RunCommand_1.RunCommand('r')); | ||
program.addCommand(new OpenCommand_1.OpenCommand('open')); | ||
program.addCommand(new OpenCommand_1.OpenCommand('o')); | ||
program.parse(); |
#!/usr/bin/env ts-node | ||
import { DBManager } from "@cyklang/core"; | ||
import { Command } from 'commander'; | ||
@@ -6,1 +7,7 @@ export declare class ModuleCommand extends Command { | ||
} | ||
/** | ||
* | ||
* @param file | ||
* @param dbManager | ||
*/ | ||
export declare function uploadModule(file: string, dbManager: DBManager): Promise<void>; |
@@ -30,3 +30,3 @@ #!/usr/bin/env ts-node | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ModuleCommand = void 0; | ||
exports.uploadModule = exports.ModuleCommand = void 0; | ||
const core_1 = require("@cyklang/core"); | ||
@@ -139,26 +139,3 @@ const fs = __importStar(require("fs")); | ||
const file = files[ind]; | ||
const dbname = getModuleDBName(file); | ||
const source = fs.readFileSync(file).toString(); | ||
const tag = (0, core_1.parseXML)(dbname, source); | ||
const dbModuleExist = await this.dbManager.dbModuleExist(dbname); | ||
if (dbModuleExist === undefined) { | ||
// insert | ||
const dbModule = new core_1.DBModule(); | ||
dbModule.source = source; | ||
dbModule.dbname = dbname; | ||
dbModule.access = tag.attributes.ACCESS; | ||
dbModule.description = tag.attributes.DESCRIPTION; | ||
logger.debug('module insert ' + dbname + ' access ' + dbModule.access + ' description ' + dbModule.description); | ||
const id = await this.dbManager.dbModuleInsert(dbModule); | ||
logger.info('module ' + dbname + ' added with ID ' + id); | ||
} | ||
else { | ||
// update | ||
dbModuleExist.source = source; | ||
dbModuleExist.access = tag.attributes.ACCESS; | ||
dbModuleExist.description = tag.attributes.DESCRIPTION; | ||
logger.debug('module update ' + dbname + ' access ' + dbModuleExist.access + ' description ' + dbModuleExist.description); | ||
await this.dbManager.dbModuleUpdate(dbModuleExist); | ||
logger.info('module ' + dbname + ' updated'); | ||
} | ||
await uploadModule(file, this.dbManager); | ||
} | ||
@@ -172,2 +149,34 @@ } | ||
} | ||
/** | ||
* | ||
* @param file | ||
* @param dbManager | ||
*/ | ||
async function uploadModule(file, dbManager) { | ||
const dbname = getModuleDBName(file); | ||
const source = fs.readFileSync(file).toString(); | ||
const tag = (0, core_1.parseXML)(dbname, source); | ||
const dbModuleExist = await dbManager.dbModuleExist(dbname); | ||
if (dbModuleExist === undefined) { | ||
// insert | ||
const dbModule = new core_1.DBModule(); | ||
dbModule.source = source; | ||
dbModule.dbname = dbname; | ||
dbModule.access = tag.attributes.ACCESS; | ||
dbModule.description = tag.attributes.DESCRIPTION; | ||
// logger.debug('module insert ' + dbname + ' access ' + dbModule.access + ' description ' + dbModule.description) | ||
const id = await dbManager.dbModuleInsert(dbModule); | ||
logger.info('module ' + dbname + ' added with ID ' + id); | ||
} | ||
else { | ||
// update | ||
dbModuleExist.source = source; | ||
dbModuleExist.access = tag.attributes.ACCESS; | ||
dbModuleExist.description = tag.attributes.DESCRIPTION; | ||
// logger.debug('module update ' + dbname + ' access ' + dbModuleExist.access + ' description ' + dbModuleExist.description) | ||
await dbManager.dbModuleUpdate(dbModuleExist); | ||
logger.info('module ' + dbname + ' updated'); | ||
} | ||
} | ||
exports.uploadModule = uploadModule; | ||
class ModuleDownload extends Cmd_1.Cmd { | ||
@@ -174,0 +183,0 @@ constructor(name, description) { |
import { Cmd } from "./Cmd"; | ||
export declare class OpenCommand extends Cmd { | ||
constructor(); | ||
constructor(name: string); | ||
openBrowser(module: string, options: any): Promise<void>; | ||
} |
@@ -12,4 +12,4 @@ "use strict"; | ||
class OpenCommand extends Cmd_1.Cmd { | ||
constructor() { | ||
super('open'); | ||
constructor(name) { | ||
super(name); | ||
this.description('open browser').version('0.1') | ||
@@ -16,0 +16,0 @@ .argument('<module>', 'module to execute') |
import { Cmd } from "./Cmd"; | ||
export declare class RunCommand extends Cmd { | ||
constructor(); | ||
constructor(name: string); | ||
runFiles(files: string[], options: any): Promise<void>; | ||
} |
@@ -39,4 +39,4 @@ "use strict"; | ||
class RunCommand extends Cmd_1.Cmd { | ||
constructor() { | ||
super('run'); | ||
constructor(name) { | ||
super(name); | ||
this.description('run module').version('0.2') | ||
@@ -43,0 +43,0 @@ .argument('<files...>', 'local module file(s) to run') |
{ | ||
"name": "@cyklang/cli", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "cyklang CLI", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -26,3 +26,3 @@ import { DBManager, DBRemote, SigninResponse, Structure } from "@cyklang/core"; | ||
if (process.env.DBREMOTE_URL === undefined) throw 'DBREMOTE_URL undefined' | ||
logger.debug('Cmd.DBREMOTE_URL ' + process.env.DBREMOTE_URL) | ||
logger.info('Cyk server: ' + process.env.DBREMOTE_URL) | ||
const nodeCrypto = new NodeCrypto() | ||
@@ -29,0 +29,0 @@ this.dbRemote = new DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto) |
@@ -10,3 +10,3 @@ #!/usr/bin/env node | ||
import { RunCommand } from './RunCommand' | ||
import { InitCommand } from './InitCommand' | ||
import { InstallCommand } from './InstallCommand' | ||
import { AssetCommand } from './AssetCommand' | ||
@@ -21,3 +21,4 @@ import { OpenCommand } from './OpenCommand' | ||
program.addCommand(new InitCommand('init')) | ||
program.addCommand(new InstallCommand('install')) | ||
program.addCommand(new InstallCommand('i')) | ||
program.addCommand(new AssetCommand('asset', 'manage assets')) | ||
@@ -34,5 +35,7 @@ program.addCommand(new AssetCommand('a', 'manage assets')) | ||
program.addCommand(new TestCommand()) | ||
program.addCommand(new RunCommand()) | ||
program.addCommand(new OpenCommand()) | ||
program.addCommand(new RunCommand('run')) | ||
program.addCommand(new RunCommand('r')) | ||
program.addCommand(new OpenCommand('open')) | ||
program.addCommand(new OpenCommand('o')) | ||
program.parse() |
#!/usr/bin/env ts-node | ||
import { DBModule, parseXML } from "@cyklang/core" | ||
import { DBManager, DBModule, parseXML } from "@cyklang/core" | ||
import * as fs from "fs" | ||
@@ -118,26 +118,3 @@ import loglevel from 'loglevel' | ||
const file = files[ind] | ||
const dbname = getModuleDBName(file) | ||
const source = fs.readFileSync(file).toString() | ||
const tag = parseXML(dbname, source) | ||
const dbModuleExist = await this.dbManager.dbModuleExist(dbname) | ||
if (dbModuleExist === undefined) { | ||
// insert | ||
const dbModule = new DBModule() | ||
dbModule.source = source | ||
dbModule.dbname = dbname | ||
dbModule.access = tag.attributes.ACCESS | ||
dbModule.description = tag.attributes.DESCRIPTION | ||
logger.debug('module insert ' + dbname + ' access ' + dbModule.access + ' description ' + dbModule.description) | ||
const id = await this.dbManager.dbModuleInsert(dbModule) | ||
logger.info('module ' + dbname + ' added with ID ' + id) | ||
} | ||
else { | ||
// update | ||
dbModuleExist.source = source | ||
dbModuleExist.access = tag.attributes.ACCESS | ||
dbModuleExist.description = tag.attributes.DESCRIPTION | ||
logger.debug('module update ' + dbname + ' access ' + dbModuleExist.access + ' description ' + dbModuleExist.description) | ||
await this.dbManager.dbModuleUpdate(dbModuleExist) | ||
logger.info('module ' + dbname + ' updated') | ||
} | ||
await uploadModule(file, this.dbManager) | ||
} | ||
@@ -152,2 +129,34 @@ } | ||
/** | ||
* | ||
* @param file | ||
* @param dbManager | ||
*/ | ||
export async function uploadModule(file: string, dbManager: DBManager) { | ||
const dbname = getModuleDBName(file) | ||
const source = fs.readFileSync(file).toString() | ||
const tag = parseXML(dbname, source) | ||
const dbModuleExist = await dbManager.dbModuleExist(dbname) | ||
if (dbModuleExist === undefined) { | ||
// insert | ||
const dbModule = new DBModule() | ||
dbModule.source = source | ||
dbModule.dbname = dbname | ||
dbModule.access = tag.attributes.ACCESS | ||
dbModule.description = tag.attributes.DESCRIPTION | ||
// logger.debug('module insert ' + dbname + ' access ' + dbModule.access + ' description ' + dbModule.description) | ||
const id = await dbManager.dbModuleInsert(dbModule) | ||
logger.info('module ' + dbname + ' added with ID ' + id) | ||
} | ||
else { | ||
// update | ||
dbModuleExist.source = source | ||
dbModuleExist.access = tag.attributes.ACCESS | ||
dbModuleExist.description = tag.attributes.DESCRIPTION | ||
// logger.debug('module update ' + dbname + ' access ' + dbModuleExist.access + ' description ' + dbModuleExist.description) | ||
await dbManager.dbModuleUpdate(dbModuleExist) | ||
logger.info('module ' + dbname + ' updated') | ||
} | ||
} | ||
interface DownloadOptions { | ||
@@ -154,0 +163,0 @@ id: string | undefined |
@@ -8,4 +8,4 @@ import { Cmd } from "./Cmd"; | ||
export class OpenCommand extends Cmd { | ||
constructor() { | ||
super('open') | ||
constructor(name: string) { | ||
super(name) | ||
this.description('open browser').version('0.1') | ||
@@ -12,0 +12,0 @@ .argument('<module>', 'module to execute') |
@@ -11,4 +11,4 @@ import { Structure, Script, XmlError, DBRemote, DBManager, ModuleInstruction, parseXML, MapData } from "@cyklang/core" | ||
export class RunCommand extends Cmd { | ||
constructor() { | ||
super('run') | ||
constructor(name: string) { | ||
super(name) | ||
this.description('run module').version('0.2') | ||
@@ -15,0 +15,0 @@ .argument('<files...>', 'local module file(s) to run') |
376562
121
5625
54