lincd-cli
Version:
Command line tools for the lincd.js library
208 lines • 9.55 kB
JavaScript
;
//The line above calls the TSX typescript executer as runtime, which extends node.js and supports running typescript
// see: https://www.npmjs.com/package/tsx
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// import babelRegister from '@babel/register';
// babelRegister({extensions: ['.ts', '.tsx']});
const cli_methods_js_1 = require("./cli-methods.js");
// import {buildMetadata} from './metadata';
require("require-extensions");
const commander_1 = require("commander");
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
commander_1.program
.command('create-app')
.action((name) => {
return (0, cli_methods_js_1.createApp)(name);
})
.description('Creates a new folder with all the required files for a LINCD app')
.argument('<name>', 'the name of your LINCD app. To use spaces, wrap the name in double quotes.');
commander_1.program
.command('start')
.action(() => {
return (0, cli_methods_js_1.startServer)();
})
.option('--env', 'The node environment to use. Default is "development"')
.description('Start the LINCD node.js server. Use --initOnly to start the backend without http server');
commander_1.program
.command('create-package')
.action((name, uriBase) => {
return (0, cli_methods_js_1.createPackage)(name, uriBase);
})
.description('Create a new folder with all the required files for a new LINCD package')
.argument('<name>', 'The name of the package. Will be used as package name in package.json')
.argument('[uri_base]', 'The base URL used for data of this package. Leave blank to use the URL of your package on lincd.org after you register it');
commander_1.program
.command('upgrade-packages')
.action(() => {
return (0, cli_methods_js_1.upgradePackages)();
})
.description('Upgrade all lincd packages in the workspace to ESM/CJS dual packages');
commander_1.program
.command('create-shape')
.action((name, uriBase) => {
return (0, cli_methods_js_1.createShape)(name);
})
.description('Creates a new ShapeClass file for your package. Execute this from your package folder.')
.argument('<name>', 'The name of the shape. Will be used for the file name and the class name');
commander_1.program
.command('create-component')
.action((name, uriBase) => {
return (0, cli_methods_js_1.createComponent)(name);
})
.description('Creates a new Component file for your package. Execute this from your package folder.')
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
commander_1.program
.command('create-set-component')
.action((name, uriBase) => {
return (0, cli_methods_js_1.createSetComponent)(name);
})
.description('Creates a new SetComponent file for your package. Execute this from your package folder.')
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
commander_1.program
.command('create-ontology')
.action((prefix, uriBase) => {
return (0, cli_methods_js_1.createOntology)(prefix, uriBase);
})
.description('Creates a new ontology file for your package. Execute this from your package folder.')
.argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
.argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package");
commander_1.program.command('app [action]', { hidden: true }).action(() => {
(0, cli_methods_js_1.register)('http://localhost:4101');
});
commander_1.program.command('register-local', { hidden: true }).action(() => {
(0, cli_methods_js_1.register)('http://localhost:4101');
});
commander_1.program.command('register-dev', { hidden: true }).action(() => {
(0, cli_methods_js_1.register)('https://dev-registry.lincd.org');
});
commander_1.program
.command('register')
.action(() => {
(0, cli_methods_js_1.register)('https://registry.lincd.org');
})
.description('Register (a new version of) this package to the LINCD registry. If successful your package will appear on www.lincd.org');
commander_1.program
.command('info')
.action(() => {
let localDir = (0, cli_methods_js_1.getScriptDir)();
let packageJsonPath = path_1.default.join(localDir, 'package.json');
try {
var ownPackage = JSON.parse(fs_extra_1.default.readFileSync(packageJsonPath, 'utf8'));
}
catch (e) {
console.warn('Could not read package.json at ' + packageJsonPath + ': ' + e);
process.exit();
}
console.log(ownPackage.version);
console.log('Running from: ' + localDir);
})
.description("Log the version of this tool and the path that it's running from");
commander_1.program
.command('build [target] [target2]', { isDefault: true })
.action((target, target2) => {
(0, cli_methods_js_1.buildPackage)(target, target2);
});
commander_1.program.command('compile-only').action(() => {
(0, cli_methods_js_1.compilePackage)();
}).description('Compile the package without other build steps. Run this command from the package folder');
commander_1.program.command('build-metadata').action(() => {
console.log('Needs to be reimplemented');
// buildMetadata();
});
commander_1.program
.command('build-app')
.action(() => {
(0, cli_methods_js_1.buildApp)();
})
.option('--env', 'The node environment to use. Default is "development"')
.description('Start the LINCD node.js server. Use --initOnly to start the backend without http server');
commander_1.program.command('publish-updated').action(() => {
return (0, cli_methods_js_1.publishUpdated)();
});
commander_1.program.command('publish [version]').action((version) => {
(0, cli_methods_js_1.publishPackage)(null, false, null, version);
});
commander_1.program.command('status').action(() => {
//log which packages need to be published
return (0, cli_methods_js_1.publishUpdated)(true).then(() => {
//log which packages need to be build
return (0, cli_methods_js_1.buildUpdated)(undefined, '', '', true);
});
});
commander_1.program
.command('build-updated [target] [target2]')
.action((target, target2, options) => {
const { useGit } = options;
return (0, cli_methods_js_1.buildUpdated)(1, target, target2, useGit || false);
})
.option('--use-git', 'Use git commit timestamps to check which packages have been updated since the last build');
commander_1.program
.command('build-updated-since [num-commits-back] [target] [target2]')
.action((back, target, target2) => {
return (0, cli_methods_js_1.buildUpdated)(back, target, target2);
});
commander_1.program
.command('build-all')
.action((options) => {
(0, cli_methods_js_1.buildAll)(options);
})
.option('--sync', 'build each package 1 by 1 - use this if you have build issues due to low available RAM memory')
.option('--from <char>', 'start from a specific package');
commander_1.program
.command('all [action] [filter] [filter-value]')
.action((command, filter, filterValue) => {
(0, cli_methods_js_1.executeCommandForEachPackage)((0, cli_methods_js_1.getLincdPackages)(), command, filter, filterValue);
});
// program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {
// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
// });
commander_1.program.command('dev [target] [mode]').action((target, mode) => {
(0, cli_methods_js_1.developPackage)(target, mode);
});
commander_1.program.command('depcheck').action((target, mode) => {
(0, cli_methods_js_1.depCheck)();
});
commander_1.program.command('depcheck-staged').action((target, mode) => {
(0, cli_methods_js_1.depCheckStaged)();
});
commander_1.program.command('check-imports').action((target, mode) => {
(0, cli_methods_js_1.checkImports)();
});
commander_1.program
.command('package')
.action((name, command, args) => {
let fullCommand = command
? command +
' ' +
' ' +
args
.slice(0, 3)
.filter((a) => a && true)
.join(' ')
: null;
//TODO: call
// let pkgName = process.argv[1];
// console.log(pkgName);
// let restArgs = process.argv.slice(2)
// program.parse([],{from:'user'});
// program.parse(['--port', '80'], { from: 'user' })
(0, cli_methods_js_1.executeCommandForPackage)(name, fullCommand);
})
.alias('p')
.alias('pkg')
.alias('m')
.alias('module')
.description('Searches for a package in this workspace with a partially matching name and executes a command for that package (without needing to execute it from the folder of the package)')
.argument('<name>', 'the name of the package. Can be a part of the name.')
.argument('[command]', 'the lincd command you want to execute. Like dev or build')
.argument('[args...]', 'the additional arguments of that command');
commander_1.program.command('enable-capacitor').action(() => {
(0, cli_methods_js_1.addCapacitor)();
});
commander_1.program.parse(process.argv);
//# sourceMappingURL=cli.js.map