Skip to content

Commit

Permalink
refactor ~ replace JSDelivr/SkyPack imports with 'esm.sh'
Browse files Browse the repository at this point in the history
* Deno-v2.0.0-rc7+ is now requiring "import" permissions
  - JSDelivr and SkyPack are not on the Deno-2.0 default allowlist
  - esm.sh *is* included in the "allow-import" default domain list
  - ref: [Proposal/discussion](denoland/deno#8266)
  - ref: [Merged solution](denoland/deno#25469)
  • Loading branch information
rivy committed Oct 13, 2024
1 parent 2f6a0bf commit a72a959
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
22 changes: 20 additions & 2 deletions src/lib/$deps.cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,26 @@
// Warning Implicitly using latest version (0.207.0) for https://deno.land/std/path/mod.ts
// Warning Implicitly using latest version (0.207.0) for https://deno.land/std/fmt/printf.ts
// ```
export { default as $yargs } from 'https://cdn.jsdelivr.net/gh/rivy-js/yargs@6be59a7fda/deno.ts'; // v17.7.2-deno-rivy
// * revise URL to use 'esm.sh' instead of 'cdn.jsdelivr.net' for compatibility with Deno-2.0 "import" permission defaults
// export { default as $yargs } from 'https://cdn.jsdelivr.net/gh/rivy-js/yargs@6be59a7fda/deno.ts'; // v17.7.2-deno-rivy
export { default as $yargs } from 'https://esm.sh/gh/rivy-js/yargs@f4b8034a75/deno.ts'; // v17.7.2-deno-rivy

//==== types

export type { Arguments as YargsArguments } from 'https://cdn.jsdelivr.net/gh/rivy-js/yargs@6be59a7fda/deno-types.ts'; // v17.7.2-deno-rivy
// export type { Arguments as YargsArguments } from 'https://esm.sh/gh/rivy-js/yargs@f4b8034a75/deno-types.ts'; // v17.7.2-deno-rivy

declare type ArgsOutput = (string | number)[];

// spell-checker:ignore () bcoe
// TODO(bcoe): attempt to get the types for YargsInstance working again.
export interface Arguments {
/** Non-option arguments */
_: ArgsOutput;
/** Arguments after the end-of-options flag `--` */
'--'?: ArgsOutput;
/** All remaining options */
// deno-lint-ignore no-explicit-any
[argName: string]: any;
}

export type { Arguments as YargsArguments };
10 changes: 8 additions & 2 deletions src/lib/$deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ export const $fs = { exists, existsSync, expandGlob, expandGlobSync };

// export { default as $xdgAppPaths } from 'https://cdn.jsdelivr.net/gh/rivy/js.xdg-app-paths@9466e97/src/mod.deno.ts';

// export * as $lodash from 'https://cdn.skypack.dev/pin/[email protected]/lodash.js';
export * as $lodash from 'https://cdn.skypack.dev/[email protected]';
export * as $cliffyTable from 'https://deno.land/x/[email protected]/table/mod.ts'; // *pin*; [email protected] == last version to use [email protected] (or lower)
export { default as $osPaths } from 'https://deno.land/x/[email protected]/src/mod.deno.ts';
export * as $semver from 'https://deno.land/x/[email protected]/mod.ts';
export * as $tty from 'https://deno.land/x/[email protected]/mod.ts';
export { default as $xdgAppPaths } from 'https://deno.land/x/[email protected]/src/mod.deno.ts';

// export * as $lodash from 'https://cdn.skypack.dev/pin/[email protected]/lodash.js';
// export * as $lodash from 'https://cdn.skypack.dev/[email protected]';
// * revise URL to use 'esm.sh' instead of 'cdn.skypack.dev' for compatibility with Deno-2.0 "import" permission defaults
// export { default as $lodash } from 'https://esm.sh/[email protected]';
// export { _ as $lodash } from 'https://esm.sh/[email protected]';
// export * as $lodash from 'https://deno.land/x/[email protected]/dist/lodash.js';
export { default as $lodash } from 'npm:[email protected]'; // requires deno-v1.25.0+; recommend deno-v1.30.0+ for better results

// export { default as $yargs } from 'https://deno.land/x/[email protected]/deno.ts';

//=== features (functions, objects, and/or values)
Expand Down
11 changes: 7 additions & 4 deletions tests/xArgs.types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ import { string, unknown } from 'https://esm.sh/v45/[email protected]';
// ToDO: evaluate [`zod`](https://github.com/colinhacks/zod) as a possible replacement for `computed-types`
// ToDO: evaluate `chai` and `sinon`; egs, <https://deno.land/[email protected]/testing/chai_example.ts> and <https://deno.land/[email protected]/testing/sinon_example.ts>

import chai from 'https://cdn.skypack.dev/[email protected]?dts';
// import sinon from 'https://cdn.skypack.dev/[email protected]?dts';
// import mocha from 'https://unpkg.com/[email protected]/mocha.js';
import { z } from 'https://cdn.skypack.dev/[email protected]?dts';
// import chai from 'https://cdn.skypack.dev/[email protected]?dts';
// // import sinon from 'https://cdn.skypack.dev/[email protected]?dts';
// // import mocha from 'https://unpkg.com/[email protected]/mocha.js';
// import { z } from 'https://cdn.skypack.dev/[email protected]?dts';

import chai from 'https://esm.sh/[email protected]';
import { z } from 'https://esm.sh/[email protected]';

import { test } from './$shared.ts';

Expand Down

0 comments on commit a72a959

Please sign in to comment.