-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demo cli #177
Demo cli #177
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
dist/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"printWidth": 110, | ||
"trailingComma": "all", | ||
"overrides": [ | ||
{ | ||
"files": "*.spec.ts", | ||
"options": { | ||
"printWidth": 5000 | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env node | ||
|
||
// setup Jasmine | ||
const Jasmine = require('jasmine'); | ||
const jasmine = new Jasmine(); | ||
jasmine.loadConfig({ | ||
spec_dir: 'build', | ||
spec_files: ['**/*.spec.js'], | ||
helpers: [], | ||
random: false, | ||
seed: null, | ||
stopSpecOnExpectationFailure: false | ||
}); | ||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15*1000; | ||
|
||
// setup console reporter | ||
const JasmineConsoleReporter = require('jasmine-console-reporter'); | ||
const reporter = new JasmineConsoleReporter({ | ||
colors: 1, // (0|false)|(1|true)|2 | ||
cleanStack: 1, // (0|false)|(1|true)|2|3 | ||
verbosity: 4, // (0|false)|1|2|(3|true)|4 | ||
listStyle: 'indent', // "flat"|"indent" | ||
activity: true, | ||
emoji: true, | ||
}); | ||
|
||
// initialize and execute | ||
jasmine.env.clearReporters(); | ||
jasmine.addReporter(reporter); | ||
jasmine.execute(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@iov/cli", | ||
"version": "0.0.0", | ||
"description": "Cli for using web4", | ||
"author": "Ethan <ethanfrey@users.noreply.github.com>", | ||
"license": "AGPL-3.0", | ||
"main": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iov-one/web4/tree/master/packages/iov-api" | ||
}, | ||
"scripts": { | ||
"cli": "ts-node --type-check -r ./src/index.ts", | ||
"lint": "tslint -t verbose --project .", | ||
"format": "prettier --write --loglevel warn './src/**/*.ts'", | ||
"test-node": "./jasmine-testrunner.js", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"prebuild": "yarn format && yarn lint", | ||
"build": "tsc", | ||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build" | ||
}, | ||
"dependencies": { | ||
"ts-node": "^7.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const a = 100; | ||
|
||
export const bigger = (x: number) => x * 5; | ||
|
||
// tslint:disable:no-console | ||
console.log(`loaded up api ${a}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// just to see if we can force the import with this | ||
export interface Foo { | ||
name: string; | ||
} | ||
|
||
declare module NodeJS { | ||
interface Global { | ||
a: number; | ||
bigger: (x: number) => number; | ||
} | ||
} | ||
|
||
declare const a: number; | ||
declare const bigger: (x: number) => number; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// I tried to add these but they just broke tsc | ||
// so it seems we can add globals defined in the same module, | ||
// but if we import anything it breaks??? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you cannot change I think the way to go is rather patch https://github.com/TypeStrong/ts-node/blob/master/src/bin.ts to let it consume some inital commands. That would bring them into the proper scope directly. |
||
|
||
// import * as code from './api'; | ||
// import {Foo} from './globals'; | ||
|
||
declare module NodeJS { | ||
interface Global { | ||
value: number; | ||
fx: (x: number) => number; | ||
} | ||
} | ||
|
||
declare const value: number; | ||
declare const fx: (x: number) => number; | ||
|
||
const a = 100; | ||
const bigger = (x: number) => x * 5; | ||
global.value = a; | ||
global.fx = bigger; | ||
|
||
// tslint:disable:no-console | ||
console.log(`set global ${global.value}`); | ||
console.log('Type fx(value)'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"rootDir": "src" | ||
}, | ||
"includes": [ | ||
"src/*.ts" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../tslint.json" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5751,6 +5751,19 @@ ts-node@^6.0.3: | |
source-map-support "^0.5.6" | ||
yn "^2.0.0" | ||
|
||
ts-node@^7.0.0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have |
||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.0.tgz#a94a13c75e5e1aa6b82814b84c68deb339ba7bff" | ||
dependencies: | ||
arrify "^1.0.0" | ||
buffer-from "^1.1.0" | ||
diff "^3.1.0" | ||
make-error "^1.1.1" | ||
minimist "^1.2.0" | ||
mkdirp "^0.5.1" | ||
source-map-support "^0.5.6" | ||
yn "^2.0.0" | ||
|
||
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: | ||
version "1.9.3" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing to be built in this package, right?