Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 4331b12

Browse files
unionalblakeembrey
authored andcommitted
Add JSPM support (#140)
1 parent 8593394 commit 4331b12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1181
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
npm-debug.log
55
/dist/
66
/typings/
7+
spec-out

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib"
3+
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"dependency-check": "dependency-check . --unused --no-dev && dependency-check . --missing --no-dev",
1515
"test-spec": "ts-node node_modules/blue-tape/bin/blue-tape.js \"src/**/*.spec.ts\" | tap-diff",
1616
"test-cov": "ts-node node_modules/istanbul/lib/cli.js cover -e .ts --print none -x \"*.d.ts\" -x \"*.spec.ts\" node_modules/blue-tape/bin/blue-tape.js -- \"src/**/*.spec.ts\" | tap-diff",
17-
"test": "npm run lint && npm run build && npm run dependency-check && npm run test-cov",
17+
"test": "npm run build && npm run dependency-check && npm run test-cov && npm run lint",
18+
"test-spec+lint": "npm run test-spec && npm run lint",
19+
"watch": "onchange -w -i \"src/**/*.ts\" -e \"**/__test__/**\" -- npm run test-spec+lint",
1820
"bootstrap": "npm install shelljs && node scripts/bootstrap.js",
1921
"prepublish": "node scripts/prepublish.js"
2022
},
@@ -51,6 +53,7 @@
5153
"has": "^1.0.1",
5254
"invariant": "^2.2.0",
5355
"is-absolute": "^0.2.3",
56+
"jspm-config": "^0.3.0",
5457
"listify": "^1.0.0",
5558
"lockfile": "^1.0.1",
5659
"make-error-cause": "^1.2.1",
@@ -81,6 +84,7 @@
8184
"dependency-check": "^2.5.1",
8285
"istanbul": "1.0.0-alpha.2",
8386
"nock": "^9.0.0",
87+
"onchange": "3.0.2",
8488
"shelljs": "^0.7.0",
8589
"tap-diff": "^0.1.1",
8690
"ts-node": "^1.1.0",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
SystemJS.config({
2+
paths: {
3+
"npm:": "jspm_packages/npm/"
4+
},
5+
browserConfig: {
6+
"baseURL": "/"
7+
}
8+
});
9+
10+
SystemJS.config({
11+
packageConfigPaths: [
12+
"npm:@*/*.json",
13+
"npm:*.json",
14+
],
15+
map: {
16+
"make-error": "npm:[email protected]"
17+
},
18+
packages: {}
19+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
3+
"deps": {},
4+
"peerDeps": {}
5+
}
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"main": "index.js",
3+
"format": "cjs",
4+
"meta": {
5+
"*.json": {
6+
"format": "json"
7+
}
8+
}
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
b58eca92530bbdb765d2d5847133b4fec748ac1299914b932bd37a50b983c5e7c90ae93bjspm-npm@[email protected]
2+
1753189ca5505b67a01be056b367285b
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Create a new error constructor instance.
3+
*/
4+
declare function makeError(name: string): makeError.Constructor<makeError.BaseError>;
5+
6+
/**
7+
* Set the constructor prototype to `BaseError`.
8+
*/
9+
declare function makeError<T extends Error>(super_: { new (...args: any[]): T }): makeError.Constructor<T & makeError.BaseError>;
10+
11+
/**
12+
* Create a specialized error instance.
13+
*/
14+
declare function makeError<T extends Error>(name: string | Function, super_: { new (...args: any[]): T }): makeError.Constructor<T>;
15+
16+
declare module makeError {
17+
/**
18+
* Use with ES6 inheritance.
19+
*/
20+
export class BaseError implements Error {
21+
message: string;
22+
name: string;
23+
stack: string;
24+
25+
constructor(message: string);
26+
}
27+
28+
export interface Constructor <T> {
29+
new (message: string): T
30+
super_: any
31+
prototype: T
32+
}
33+
}
34+
35+
export = makeError;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "my-module",
3+
"version": "0.1.2",
4+
"jspm": {
5+
"dependencies": {
6+
"make-error": "npm:make-error@^1.2.0"
7+
}
8+
}
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="modules/make-error/index.d.ts" />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Generated by typings
2+
// Source: jspm_packages/npm/[email protected]/index.d.ts
3+
declare module 'make-error' {
4+
/**
5+
* Create a new error constructor instance.
6+
*/
7+
function makeError(name: string): makeError.Constructor<makeError.BaseError>;
8+
9+
/**
10+
* Set the constructor prototype to `BaseError`.
11+
*/
12+
function makeError<T extends Error>(super_: { new (...args: any[]): T }): makeError.Constructor<T & makeError.BaseError>;
13+
14+
/**
15+
* Create a specialized error instance.
16+
*/
17+
function makeError<T extends Error>(name: string | Function, super_: { new (...args: any[]): T }): makeError.Constructor<T>;
18+
19+
module makeError {
20+
/**
21+
* Use with ES6 inheritance.
22+
*/
23+
export class BaseError implements Error {
24+
message: string;
25+
name: string;
26+
stack: string;
27+
28+
constructor(message: string);
29+
}
30+
31+
export interface Constructor <T> {
32+
new (message: string): T
33+
super_: any
34+
prototype: T
35+
}
36+
}
37+
38+
export = makeError;
39+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"resolution": "main",
3+
"tree": {
4+
"src": "/Users/hwong/github/typings/core/src/__test__/jspm-typings-registry/jspm_packages/npm/[email protected]/package.json",
5+
"raw": "jspm:make-error"
6+
}
7+
}

src/install.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ test('install', t => {
129129
}
130130
})
131131
})
132+
.then(
133+
() => {
134+
rc.urlRewrites = {}
135+
},
136+
() => {
137+
rc.urlRewrites = {}
138+
})
132139
})
133140

134141
t.test('install empty', t => {
@@ -150,3 +157,18 @@ test('install', t => {
150157
})
151158
})
152159
})
160+
161+
test('install jspm module without package.json', t => {
162+
const emitter = new EventEmitter()
163+
const FIXTURE_DIR = join(__dirname, '__test__/jspm-typings-registry')
164+
return installDependencyRaw('jspm:make-error', {
165+
cwd: FIXTURE_DIR,
166+
emitter
167+
})
168+
.then(function () {
169+
return readFile(join(FIXTURE_DIR, 'typings/index.d.ts'), 'utf8')
170+
})
171+
.then(index => {
172+
t.equal(index, '/// <reference path="modules/make-error/index.d.ts" />\n')
173+
})
174+
})

src/interfaces/dependencies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Browser } from './config'
66
export interface Dependency {
77
type: string
88
raw: string
9-
location: string
9+
location?: string
1010
meta: DependencyMeta
1111
}
1212

@@ -41,6 +41,7 @@ export interface DependencyTree {
4141
parent?: DependencyTree
4242
files?: string[]
4343
postmessage?: string
44+
type?: string
4445
src: string
4546
raw: string
4647
global: boolean
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# jspm-typings-github
2+
3+
- typings.json with `github:` dependencies
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
SystemJS.config({
2+
paths: {
3+
"npm:": "jspm_packages/npm/"
4+
},
5+
browserConfig: {
6+
"baseURL": "/"
7+
}
8+
});
9+
10+
SystemJS.config({
11+
packageConfigPaths: [
12+
"npm:@*/*.json",
13+
"npm:*.json"
14+
],
15+
map: {
16+
"unthenify": "npm:[email protected]"
17+
},
18+
packages: {
19+
20+
"map": {
21+
"util-arity": "npm:[email protected]"
22+
}
23+
}
24+
}
25+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
3+
"deps": {
4+
"util-arity": "npm:util-arity@^1.0.2"
5+
},
6+
"peerDeps": {}
7+
},
8+
9+
"deps": {},
10+
"peerDeps": {}
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"main": "dist/index.js",
3+
"format": "cjs",
4+
"meta": {
5+
"*.json": {
6+
"format": "json"
7+
}
8+
},
9+
"map": {
10+
"./dist": "./dist/index.js"
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Promise } from 'es6-promise';
2+
declare function unthenify<U>(fn: () => Promise<U>): (cb: unthenify.Callback<U>) => any;
3+
declare function unthenify<T1, U>(fn: (a: T1) => Promise<U>): (a: T1, cb: unthenify.Callback<U>) => any;
4+
declare function unthenify<T1, T2, U>(fn: (a: T1, b: T2) => Promise<U>): (a: T1, b: T2, cb: unthenify.Callback<U>) => any;
5+
declare function unthenify<T1, T2, T3, U>(fn: (a: T1, b: T2, c: T3) => Promise<U>): (a: T1, b: T2, c: T3, cb: unthenify.Callback<U>) => any;
6+
declare function unthenify<T1, T2, T3, T4, U>(fn: (a: T1, b: T2, c: T3, d: T4) => Promise<U>): (a: T1, b: T2, c: T3, d: T4, cb: unthenify.Callback<U>) => any;
7+
declare function unthenify<T1, T2, T3, T4, T5, U>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise<U>): (a: T1, b: T2, c: T3, d: T4, e: T5, cb: unthenify.Callback<U>) => any;
8+
declare function unthenify<T1, T2, T3, T4, T5, T6, U>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6) => Promise<U>): (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, cb: unthenify.Callback<U>) => any;
9+
declare namespace unthenify {
10+
type Callback<T> = (error: Error, result: T) => any;
11+
}
12+
export = unthenify;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "unthenify",
3+
"version": "1.0.2",
4+
"description": "Callbackify a promise function. The logical reverse of `thenify`.",
5+
"main": "dist/index.js",
6+
"files": [
7+
"dist/",
8+
"typings.json",
9+
"LICENSE"
10+
],
11+
"scripts": {
12+
"lint": "tslint \"src/**/*.ts\"",
13+
"build": "rm -rf dist/ && tsc",
14+
"test-spec": "ts-node node_modules/blue-tape/bin/blue-tape.js \"src/**/*.spec.ts\" | tap-spec",
15+
"test-cov": "ts-node node_modules/istanbul/lib/cli.js cover -e .ts --print none -x \"*.d.ts\" -x \"*.spec.ts\" blue-tape -- \"src/**/*.spec.ts\" | tap-spec",
16+
"test": "npm run lint && npm run test-cov",
17+
"prepublish": "typings install && npm run build"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git://github.com/blakeembrey/unthenify.git"
22+
},
23+
"keywords": [
24+
"thenify",
25+
"promise",
26+
"callback",
27+
"nodeify",
28+
"then"
29+
],
30+
"author": {
31+
"name": "Blake Embrey",
32+
"email": "[email protected]",
33+
"url": "http://blakeembrey.me"
34+
},
35+
"license": "Apache-2.0",
36+
"bugs": {
37+
"url": "https://github.com/blakeembrey/unthenify/issues"
38+
},
39+
"homepage": "https://github.com/blakeembrey/unthenify",
40+
"devDependencies": {
41+
"any-promise": "^1.1.0",
42+
"blue-tape": "^0.2.0",
43+
"bluebird": "^3.1.1",
44+
"istanbul": "1.0.0-alpha.2",
45+
"tap-spec": "^4.1.1",
46+
"ts-node": "^0.9.2",
47+
"tslint": "^3.1.1",
48+
"typescript": "^1.7.3",
49+
"typings": "^1.3.0"
50+
},
51+
"dependencies": {
52+
"util-arity": "^1.0.2"
53+
}
54+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"globalDependencies": {
3+
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729"
4+
},
5+
"dependencies": {
6+
"es6-promise": "github:typings/typed-es6-promise#94aac67ef7a14a8de8e9e1d3c1f9a26caa0d9fb1"
7+
},
8+
"devDependencies": {
9+
"any-promise": "github:typings/typed-any-promise#74ba6cf22149ff4de39c2338a9cb84f9ded6f042",
10+
"blue-tape": "github:typings/typed-blue-tape#a4e41a85d6f760e7c60088127968eae7d3a556fa"
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"main": "arity.js",
3+
"format": "cjs",
4+
"meta": {
5+
"*.json": {
6+
"format": "json"
7+
}
8+
}
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare function arity (arity: number, fn: (...args: any[]) => any): (...args: any[]) => any;
2+
3+
export = arity;

0 commit comments

Comments
 (0)