Skip to content

Commit

Permalink
feat(cli-core): add a new package for cli in TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Apr 8, 2020
1 parent d6e2c5c commit 4c6de2e
Show file tree
Hide file tree
Showing 26 changed files with 7,994 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli-core/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
27 changes: 27 additions & 0 deletions packages/cli-core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) IBM Corp. 2020.
Node module: @loopback/cli-core
This project is licensed under the MIT License, full text below.

--------

MIT License

MIT License Copyright (c) IBM Corp. 2020

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions packages/cli-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @loopback/cli-core

[![LoopBack](<https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)[email protected]>)](http://loopback.io/)
47 changes: 47 additions & 0 deletions packages/cli-core/bin/cli-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

const pkg = require('../package.json');
const semver = require('semver');

// Make sure node version meets the requirement. This code intentionally only
// uses ES5 features so that it can be run with lower versions of Node
// to report the version requirement.
const nodeVer = process.versions.node;
const requiredVer = pkg.engines.node;
const ok = semver.satisfies(nodeVer, requiredVer);
if (!ok) {
const format = 'Node.js %s is not supported. Please use a version %s.';
console.error(format, nodeVer, requiredVer);
process.exit(1);
}

// Intentionally have a separate `main.js` which can use JS features
// supported by required version of Node
const minimist = require('minimist');
const {main} = require('../dist/cli');
const opts = minimist(process.argv.slice(2), {
alias: {
version: 'v', // --version or -v: print versions
commands: 'l', // --commands or -l: print commands
help: 'h', // --help or -l: print help
},
});

const updateNotifier = require('update-notifier');
// Force version check with `lb4 --version`
const interval = opts.version ? 0 : undefined;
updateNotifier({
pkg: pkg,
updateCheckInterval: interval,
}).notify({isGlobal: true});

main(opts).catch(err => {
console.error(err);
process.exit(1);
});
6 changes: 6 additions & 0 deletions packages/cli-core/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/cli-core
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './dist';
6 changes: 6 additions & 0 deletions packages/cli-core/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/cli-core
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

module.exports = require('./dist');
6 changes: 6 additions & 0 deletions packages/cli-core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/cli-core
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './src';
Loading

0 comments on commit 4c6de2e

Please sign in to comment.