Skip to content
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

deprecate: undeprecate the reinstall feature #337

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14.x, 16.x]
node: [18.x, 20.x, 21.x]
deno: ['1']
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 17 additions & 7 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,17 @@ export class Generator {
* Link a module, installing all dependencies necessary into the map
* to support its execution including static and dynamic module imports.
*
* @param specifier Module to link
* @param specifier Module or list of modules to link
* @param parentUrl Optional parent URL
*/
async link(
specifier?: string | string[],
specifier: string | string[],
parentUrl?: string
): Promise<{ staticDeps: string[]; dynamicDeps: string[] }> {
if (typeof specifier === "string") specifier = [specifier];
let error = false;
if (this.installCnt++ === 0) this.traceMap.startInstall();
await this.traceMap.processInputMap;
if (!specifier || specifier.length === 0) {
const { map, staticDeps, dynamicDeps } = await this.traceMap.finishInstall();
this.map = map;
return { staticDeps, dynamicDeps };
}
specifier = specifier.map((specifier) => specifier.replace(/\\/g, "/"));
try {
await Promise.all(
Expand Down Expand Up @@ -1010,6 +1005,21 @@ export class Generator {
}
}

/**
* Locking install, retraces all top-level pins but does not change the
* versions of anything (similar to "npm ci").
*/
async reinstall() {
if (this.installCnt++ === 0) this.traceMap.startInstall();
await this.traceMap.processInputMap;
if (--this.installCnt === 0) {
const { map, staticDeps, dynamicDeps } =
await this.traceMap.finishInstall();
this.map = map;
return { staticDeps, dynamicDeps };
}
}

/**
* Updates the versions of the given packages to the latest versions
* compatible with their parent's package.json ranges. If no packages are
Expand Down
2 changes: 1 addition & 1 deletion test/api/providerswitch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const generator = new Generator({

// The generator should swap the provider from skypack to jspm.io.
// TODO: once we land defaultProvider changes this test will break
await generator.install();
await generator.reinstall();

const json = generator.getMap();
assert(json.imports.react.startsWith("https://ga.jspm.io/npm:"));
4 changes: 2 additions & 2 deletions test/api/reenv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import assert from "assert";
env: ["production", "browser"],
});

await generator.link();
await generator.reinstall();
const json = generator.getMap();

assert.strictEqual(
Expand Down Expand Up @@ -50,7 +50,7 @@ import assert from "assert";
},
});

await generator.link();
await generator.reinstall();

const json = generator.getMap();

Expand Down
File renamed without changes.
48 changes: 24 additions & 24 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scopes": {
"../": {
"#fetch": "../dist/fetch-native.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/plugin-syntax-import-assertions": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@jspm/import-map": "https://ga.jspm.io/npm:@jspm/[email protected]/dist/map.js",
Expand All @@ -23,19 +23,19 @@
"url": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js"
},
"https://ga.jspm.io/": {
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/config/files/index-browser.js",
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/config/resolve-targets-browser.js",
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/transform-file-browser.js",
"#node.js": "https://ga.jspm.io/npm:[email protected].1/browser.js",
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/config/files/index-browser.js",
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/config/resolve-targets-browser.js",
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/transform-file-browser.js",
"#node.js": "https://ga.jspm.io/npm:[email protected].2/browser.js",
"@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/[email protected]/dist/remapping.umd.js",
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.22.13/lib/index.js",
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/[email protected].3/native-modules.js",
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/[email protected].3/plugins.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/generator": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.23.5/lib/index.js",
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/[email protected].5/native-modules.js",
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/[email protected].5/plugins.js",
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/generator": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-compilation-targets": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.22.15/lib/index.js",
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.23.5/lib/index.js",
"@babel/helper-environment-visitor": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-function-name": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-hoist-variables": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
Expand All @@ -48,34 +48,34 @@
"@babel/helper-simple-access": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-split-export-declaration": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.22.5/lib/index.js",
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.23.4/lib/index.js",
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.22.15/lib/index.js",
"@babel/helpers": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/index.js",
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.22.20/lib/index.js",
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.23.5/lib/index.js",
"@babel/helpers": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.23.4/lib/index.js",
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/plugin-syntax-jsx": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/plugin-syntax-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/plugin-transform-modules-commonjs": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/template": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/traverse": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
"@babel/traverse": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
"@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/gen-mapping.umd.js",
"@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/resolve-uri.umd.js",
"@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/set-array.umd.js",
"@jridgewell/sourcemap-codec": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/sourcemap-codec.umd.js",
"@jridgewell/trace-mapping": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/trace-mapping.umd.js",
"ansi-styles": "https://ga.jspm.io/npm:[email protected]/index.js",
"browserslist": "https://ga.jspm.io/npm:[email protected].1/index.js",
"browserslist": "https://ga.jspm.io/npm:[email protected].2/index.js",
"buffer": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js",
"caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:[email protected].30001563/dist/unpacker/agents.js",
"caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:[email protected].30001566/dist/unpacker/agents.js",
"chalk": "https://ga.jspm.io/npm:[email protected]/index.js",
"color-convert": "https://ga.jspm.io/npm:[email protected]/index.js",
"color-name": "https://ga.jspm.io/npm:[email protected]/index.js",
"convert-source-map": "https://ga.jspm.io/npm:[email protected]/index.js",
"debug": "https://ga.jspm.io/npm:[email protected]/src/browser.js",
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].585/versions.js",
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].609/versions.js",
"escape-string-regexp": "https://ga.jspm.io/npm:[email protected]/index.js",
"fs": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
"gensync": "https://ga.jspm.io/npm:[email protected]/index.js",
Expand All @@ -84,8 +84,8 @@
"jsesc": "https://ga.jspm.io/npm:[email protected]/jsesc.js",
"lru-cache": "https://ga.jspm.io/npm:[email protected]/index.js",
"ms": "https://ga.jspm.io/npm:[email protected]/index.js",
"node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:[email protected].13/data/processed/envs.json.js",
"node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:[email protected].13/data/release-schedule/release-schedule.json.js",
"node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:[email protected].14/data/processed/envs.json.js",
"node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:[email protected].14/data/release-schedule/release-schedule.json.js",
"path": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js",
"process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process-production.js",
"semver": "https://ga.jspm.io/npm:[email protected]/semver.js",
Expand Down