-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
0 parents
commit 856d3eb
Showing
15 changed files
with
3,191 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.DS_Store | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
docs/_build | ||
docs/doctrees | ||
|
||
build | ||
node_modules | ||
npm-debug.log | ||
|
||
scratch/ | ||
|
||
*.pyc | ||
|
||
.idea | ||
*.sublime-* | ||
|
||
|
||
dist/ | ||
coverage/ |
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,4 @@ | ||
import {setupCordova} from './lib/Setup'; | ||
const argv = require('yargs').boolean('debug').argv; | ||
|
||
setupCordova(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,51 @@ | ||
import Chalk from 'chalk'; | ||
import {Answers, ui} from 'inquirer'; | ||
import {Step, BaseStep} from './steps/Step'; | ||
|
||
function prepareMessage(msg: any) { | ||
if (typeof msg === 'string') { | ||
return msg; | ||
} | ||
return JSON.stringify(msg); | ||
} | ||
|
||
export function l(msg: string) { | ||
console.log(msg); | ||
} | ||
|
||
export function nl() { | ||
return l(''); | ||
} | ||
|
||
export function green(msg: string) { | ||
return l(Chalk.green(prepareMessage(msg))); | ||
} | ||
|
||
export function dim(msg: string) { | ||
return l(Chalk.dim(prepareMessage(msg))); | ||
} | ||
|
||
export function debug(msg: any) { | ||
return l(Chalk.italic.yellow(prepareMessage(msg))); | ||
} | ||
|
||
export function bottomBarLoader(msg: any): [any, NodeJS.Timer] { | ||
let loader = ['/', '|', '\\', '-']; | ||
let i = 4; | ||
let bottomBar = new ui.BottomBar({bottomBar: loader[i % 4]}); | ||
let interval = setInterval(function() { | ||
bottomBar.updateBottomBar(`${loader[i++ % 4]} ${msg}`); | ||
}, (Math.random() * 300 + 50)); | ||
return [bottomBar, interval]; | ||
} | ||
|
||
export function startWizard<M extends Step>(argv: any, | ||
...steps: {new (debug: boolean): M}[] | ||
): Promise<Answers> { | ||
if (argv.debug) console.log(argv); | ||
return steps.map(step => new step(argv.debug)).reduce(async (answer, step) => { | ||
let prevAnswer = await answer; | ||
let answers = await step.emit(prevAnswer); | ||
return Promise.resolve(Object.assign({}, prevAnswer, answers)); | ||
}, Promise.resolve({})); | ||
} |
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,22 @@ | ||
import Welcome from './steps/Welcome'; | ||
import OpenSentry from './steps/OpenSentry'; | ||
import WaitForSentry from './steps/WaitForSentry'; | ||
import Initial from './steps/Initial'; | ||
import PromptTest from './steps/PromptTest'; | ||
import ProjectSelector from './steps/ProjectSelector'; | ||
import {startWizard, green} from './Helper'; | ||
|
||
export function setupCordova(argv: any) { | ||
startWizard(argv, | ||
Initial, | ||
Welcome, | ||
OpenSentry, | ||
WaitForSentry, | ||
ProjectSelector, | ||
Welcome, | ||
PromptTest, | ||
Welcome, | ||
PromptTest, | ||
Initial | ||
); | ||
} |
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,14 @@ | ||
import {BaseStep} from './Step'; | ||
import {dim} from '../Helper'; | ||
const pj = require('../../package.json'); | ||
|
||
export default class Initial extends BaseStep { | ||
emit() { | ||
dim('Starting Sentry setup...'); | ||
dim(`version: ${pj.version}`); | ||
// TODO: get sentry cli version | ||
let sentryCliVersion = 'TODO'; | ||
dim(`sentry-cli version: ${sentryCliVersion}`); | ||
return Promise.resolve({}); | ||
} | ||
} |
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,16 @@ | ||
import {BaseStep} from './Step'; | ||
import {l, green, dim, nl} from '../Helper'; | ||
let open = require('open'); | ||
|
||
export default class OpenSentry extends BaseStep { | ||
emit() { | ||
let url = 'https://sentry.io/wiz/3928f9833nv39unf230dfj2030fh230fh230f8h'; | ||
open(url); | ||
nl(); | ||
l('Please open'); | ||
green(url); | ||
l('in your browser'); | ||
nl(); | ||
return Promise.resolve({}); | ||
} | ||
} |
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,21 @@ | ||
import {prompt, Question, Answers} from 'inquirer'; | ||
import {BaseStep} from './Step'; | ||
import {dim} from '../Helper'; | ||
|
||
export default class ProjectSelector extends BaseStep { | ||
emit(answers?: Answers) { | ||
this.debug(answers); | ||
return prompt([ | ||
{ | ||
type: 'list', | ||
name: 'project', | ||
message: 'Please select your project:', | ||
choices: [ | ||
{name: 'Sentry / Sentry - Test', value: '1'}, | ||
{name: 'Sentry / iOS', value: '2'}, | ||
{name: 'Sentry / Android', value: '3'} | ||
] | ||
} | ||
]); | ||
} | ||
} |
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,10 @@ | ||
import {prompt, Question, Answers} from 'inquirer'; | ||
import {BaseStep} from './Step'; | ||
import {dim} from '../Helper'; | ||
|
||
export default class PromptTest extends BaseStep { | ||
emit(answers?: Answers) { | ||
this.debug(answers); | ||
return prompt([{name: `${Math.floor(Math.random() * 100)}`, message: 'yeah'}]); | ||
} | ||
} |
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,14 @@ | ||
import {Answers} from 'inquirer'; | ||
import {debug} from '../Helper'; | ||
|
||
export abstract class BaseStep implements Step { | ||
constructor(protected isDebug = false) {} | ||
abstract emit(answers?: Answers): Promise<Answers>; | ||
debug(msg: any) { | ||
if (this.isDebug) debug(msg); | ||
} | ||
} | ||
|
||
export interface Step { | ||
emit(answers?: Answers): Promise<Answers>; | ||
} |
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,17 @@ | ||
import {BaseStep} from './Step'; | ||
import {l, green, dim, nl, bottomBarLoader} from '../Helper'; | ||
|
||
export default class WaitForSentry extends BaseStep { | ||
emit() { | ||
return new Promise(resolve => { | ||
let [bottomBar, interval] = bottomBarLoader('Waiting for Sentry...'); | ||
// Simulates request | ||
setTimeout(() => { | ||
clearInterval(interval); | ||
bottomBar.close(); | ||
nl(); | ||
resolve(); | ||
}, 5000); | ||
}); | ||
} | ||
} |
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,18 @@ | ||
import {BaseStep} from './Step'; | ||
import {l, green, dim, nl} from '../Helper'; | ||
|
||
export default class Welcome extends BaseStep { | ||
private static didShow = false; | ||
emit() { | ||
if (Welcome.didShow) return Promise.resolve({}); | ||
nl(); | ||
green('You are about to configure Sentry for your project'); | ||
dim('We will ask you a bunch of questions to configure Sentry for you.'); | ||
nl(); | ||
l('You will need the DSN and an API key for the application to proceed.'); | ||
l('The keys can be found the project settings and at sentry.io/api/'); | ||
nl(); | ||
Welcome.didShow = true; | ||
return Promise.resolve({}); | ||
} | ||
} |
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,67 @@ | ||
{ | ||
"name": "@sentry/sentry-cli", | ||
"version": "0.1.0", | ||
"description": "Sentry command line helper", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"typescript": { | ||
"definition": "dist/index.d.ts" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.3.0", | ||
"inquirer": "^3.3.0", | ||
"open": "^0.0.5", | ||
"sentry-cli-binary": "^1.21.0", | ||
"yargs": "^10.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/inquirer": "^0.0.35", | ||
"@types/jest": "^21.1.2", | ||
"@types/node": "^8.0.32", | ||
"jest": "^21.2.1", | ||
"prettier": "^1.7.4", | ||
"ts-jest": "^21.1.2", | ||
"ts-node": "^3.3.0", | ||
"typescript": "^2.5.3" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.5 <9.0.0", | ||
"npm": ">=3.10.7 <6.0.0", | ||
"yarn": ">=1.0.2 <2.0.0" | ||
}, | ||
"scripts": { | ||
"clean": "rm -rf ./dist", | ||
"dist": "npm run clean && tsc -p tsconfig.json", | ||
"test": "npm run dist && jest", | ||
"try": "ts-node index.ts --sentry-url=http://localhost:8000 --debug", | ||
"test:watch": "jest --watch --notify" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"coveragePathIgnorePatterns": [ | ||
"dist" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
], | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>/dist/__mocks__" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"\\.d\\.(jsx?|tsx?)$", | ||
"\\.no-jest\\.(jsx?|tsx?)$" | ||
] | ||
}, | ||
"author": "Sentry", | ||
"license": "MIT" | ||
} |
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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"stripInternal": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es2015"], | ||
"skipLibCheck": true, | ||
"types": [], | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"sourceMap": true, | ||
"inlineSources": 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,17 @@ | ||
{ | ||
"extends": "./tsconfig.build.json", | ||
|
||
"compilerOptions": { | ||
"types": [ | ||
"node" | ||
], | ||
"declaration": true, | ||
"outDir": "dist" | ||
}, | ||
"include": [ | ||
"__tests__", | ||
"index.ts", | ||
"lib/**/*", | ||
"spec/**/*" | ||
] | ||
} |
Oops, something went wrong.