UNPKG

5.79 kBMarkdownView Raw
1jspm delegates all specific repository operations including lookups, downloads and build operations to registry modules.
2
3For example, the [jspm registry](https://github.com/jspm/registry-endpoint), [GitHub registry](https://github.com/jspm/github/), or [npm registry](https://github.com/jspm/npm).
4
5Custom registries can be easily created by exporting a new package following this Registry API.
6
7Please do ask questions or create suggestions to help make this documentation better.
8
9# Registry API Version 2.0
10
11### Constructor
12
13```
14 new Registry(options, ui)
15```
16
17Options includes:
18
19* `apiVersion` is the current registry API version string of the form `MAJOR`.`MINOR` (patch versions are not applicable to an API since all changes are public API changes).
20* `versionString` represents the minor and major version of the registry package, which is used in the caching hash of packages. This can be altered and written to the instance allowing for custom registry cache invalidation - `this.versionString = options.versionString + '.53'`.
21* `timeouts` an object containing timeouts for hooks. Values are in seconds that will apply before a registry hook call is retried automatically. The registry hook should cancel any requests after this timeout time as their responses won't be used after that. Registry promise errors will also result in a retry.
22 * `timeouts.lookups` used for all lookup-style hooks, default is 60 seconds.
23 * `timeouts.download` used for the download hook, default is 300 seconds.
24 * `timeouts.build` used for the build hook, default is 300 seconds, with no retry.
25* `tmpDir` is a folder the registry can use to store temporary files. This folder persists and is shared between installs.
26* Any other options are as set from the registry-specific config.
27
28### Error Handling
29
30All hooks can reject with an error. By default all errors are assumed terminal and will abort the entire install.
31
32#### Retriable Errors
33
34Network errors that are retriable can be indicated by setting `e.retriable = true`, in which case the hook that failed will be re-called up to the limit.
35
36#### Configuration Errors
37
38Errors that are due to authentication and server configuration can be indicated via `e.config = true`. In these cases, the endpoint will run through reconfiguration before being initialized again with the new configuration for a retry.
39
40### Methods
41
42#### locate(packageName), optional
43
44```
45 -> Promise { notfound: true } / { redirect: 'new:package' } / undefined
46```
47
48#### lookup(packageName)
49```
50 -> Promise { notfound: true }
51 / { versions: {
52 '1.2.3': { hash: 'asdf' },
53 'branch-name': { hash: '8j3mjw8fwef7a', stable: false, meta: { custom: 'lookup data' } }
54 } }
55```
56* Version map object has hash as only required property.
57* Stable set to false allows versions to opt-out of semver matching, and need exact matches only.
58* meta can contain other lookup data that will be returned to the download function.
59* Only versions that are valid semvers will be selected when doing version install ranges.
60
61#### download (packageName, version, hash, meta, targetDir)
62```
63 -> Promise packageConfig
64```
65
66* Downloads into `targetDir`
67* Only needs to return the package config if no `getPackageConfig` hook is provided.
68
69#### getPackageConfig (packageName, version, hash, meta), optional
70```
71 -> Promise package config, always takes preference over download package config
72```
73* Allows for downloads not to block dependency tree discovery
74
75#### processPackageConfig (packageConfig, packageName), optional
76```
77 -> Promise processed packageConfig
78```
79
80* Used to apply modification operations to the package configuration prior to build operations.
81* The `dependencies` returned will be immediately used for preloading dependencies in parallel to downloads.
82* This function, as well as the build, are separated from the transport implementations to enable linking workflows.
83* Package configuration provided already has overrides included, and any `jspm` property merged in as well. The `jspm` property containing the derived override that was applied is still provided.
84
85#### processPackage (packageConfig, packageName, packageDir), optional
86```
87 -> Promise processed packageConfig
88```
89* With the package files present, further configuration processing can be appiled before returning the final packageConfig.
90* The main entry point can still be specified in the packageConfig
91* Additional dependencies can be added to the packageConfig, in which case they will be downloaded after build.
92* Dependencies cannot be modified or removed though due to preloading.
93
94#### getOverride(registry, packageName, versionRange, override)
95
96```
97 -> override
98```
99
100* **For the default registry only (jspm registry).**
101* The registry can also provide overrides for all packages for all other registries, as well as the locate hook which allows the registry locating.
102* It is configured through `jspm config defaultRegistry registryName`.
103
104#### static packageNameFormats
105
106An array of wildcard expressions that can be used to match a given package name for this registry.
107
108For example, for `github:components/jquery@1.2.3`, the package path format is `*/*`, where the `*` will not match deeply.
109
110For npm, the package path formats are `['*', '@*/*']` to support normal names and scopes like `npm:@scope/name`.
111
112This makes it possible to determine from any package expression like `npm:@some/package/path` which part of the expression describes the package name and which part describes a path within the package.
113
114If no value is provided, the default is taken to be `['*']`.
115
116#### static configure (config, ui), optional
117```
118 -> Promise for config
119```
120
121#### static remote, optional
122```
123 -> remote URL used for jspm setmode remote and injection
124```
125* Static property
\No newline at end of file