-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e2e44a
commit 93e79e1
Showing
15 changed files
with
206 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var commander_1 = require("commander"); | ||
var index_1 = require("./index"); | ||
var logger_1 = tslib_1.__importDefault(require("./utils/logger")); | ||
var cli = commander_1.program.version(require('../package.json').version).name('bin-template'); | ||
cli.option('-c, --check', 'check is alfred installed').action(function () { | ||
if (!index_1.isInstallAlfred()) { | ||
logger_1.default.log('alfred is not installed'); | ||
// exit with success | ||
process.exit(0); | ||
} | ||
logger_1.default.log('alfred is installed'); | ||
// exit with fail | ||
process.exit(1); | ||
}); | ||
commander_1.program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isInstallAlfred = void 0; | ||
var tslib_1 = require("tslib"); | ||
var fs_1 = tslib_1.__importDefault(require("fs")); | ||
var isInstallAlfred = function () { | ||
return fs_1.default.existsSync('/Applications/Alfred 4.app/'); | ||
}; | ||
exports.isInstallAlfred = isInstallAlfred; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
// refs: https://github.com/vuejs/vue-cli/blob/v2/lib/logger.js | ||
var util_1 = require("util"); | ||
var chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
/** | ||
* Prefix. | ||
*/ | ||
var sep = chalk_1.default.gray('·'); | ||
/** | ||
* Log a `message` to the console. | ||
* | ||
* @param {String} message | ||
*/ | ||
var log = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var msg = util_1.format.apply(util_1.format, args); | ||
console.log(chalk_1.default.bgBlue.black(' info '), sep, msg); | ||
}; | ||
/** | ||
* Log an error `message` to the console and exit. | ||
* | ||
* @param {String} message | ||
*/ | ||
var fatal = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (args[0] instanceof Error) | ||
args[0] = args[0].message.trim(); | ||
var msg = util_1.format.apply(util_1.format, args); | ||
console.error(chalk_1.default.bgRed.black(' failed '), sep, msg); | ||
process.exit(1); | ||
}; | ||
/** | ||
* Log a success `message` to the console and exit. | ||
* | ||
* @param {String} message | ||
*/ | ||
var success = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var msg = util_1.format.apply(util_1.format, args); | ||
console.log(chalk_1.default.bgGreen.black(' success '), sep, msg); | ||
}; | ||
exports.default = { | ||
log: log, | ||
fatal: fatal, | ||
success: success, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var execa_1 = tslib_1.__importDefault(require("execa")); | ||
var path_1 = tslib_1.__importDefault(require("path")); | ||
var package_json_1 = tslib_1.__importDefault(require("../package.json")); | ||
var cli = path_1.default.resolve(__dirname, '../lib/cli.js'); | ||
describe('version', function () { | ||
it('print version should work', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var stdout; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, execa_1.default.node(cli, ['-V'])]; | ||
case 1: | ||
stdout = (_a.sent()).stdout; | ||
expect(stdout).toBe(package_json_1.default.version); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it('check install should work', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var exitCode; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, execa_1.default | ||
.node(cli, ['-c'], { stderr: 'inherit' }) | ||
.catch(function () { return ({ exitCode: 1 }); })]; | ||
case 1: | ||
exitCode = (_a.sent()).exitCode; | ||
if (process.platform === 'darwin') { | ||
expect(exitCode).toBe(1); | ||
} | ||
else { | ||
expect(exitCode).toBe(0); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "CommonJS", | ||
"lib": ["ES2020", "DOM"], | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"baseUrl": ".", | ||
"downlevelIteration": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'alfy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "CommonJS", | ||
"lib": ["ES2020", "DOM"], | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"baseUrl": ".", | ||
"downlevelIteration": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'alfy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "CommonJS", | ||
"lib": ["ES2020", "DOM"], | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"baseUrl": ".", | ||
"downlevelIteration": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'alfy' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters