@jsenv/core 39.2.0 → 39.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +26 -37
  2. package/dist/jsenv_core.js +18 -10
  3. package/package.json +11 -11
package/README.md CHANGED
@@ -10,29 +10,32 @@ Jsenv is a suite of tools that can be used in projects involving JavaScript.
10
10
  4. **test runner**; execute all test files at once
11
11
 
12
12
  It favors standards and simplicity.
13
- As a result it can be enjoyed by people without much experience in tooling or seeking for simple tools without hidden complexities
13
+ As a result it can be enjoyed by people without much experience in tooling or seeking for simple tools without hidden complexities.
14
14
 
15
- Now what do you want to do?
15
+ If you want to try jsenv on your machine, use [#CLI](#cli).
16
16
 
17
- | Scenario | Action |
18
- | ----------------------------------------------------- | ---------------------------------------------------- |
19
- | I want to try a demo on my machine | Go to [./demos](#demos) |
20
- | I want to try jsenv on a project I have on my machine | Go to [./cli](#cli) |
21
- | I want to learn how to use jsenv | Go to [./docs/users/users.md](./docs/users/users.md) |
17
+ Link to [documentation](./docs/users/users.md)
22
18
 
23
- # Demos
19
+ # CLI
20
+
21
+ The following command helps to init jsenv on your machine.
22
+
23
+ ```console
24
+ npm @jsenv/cli
25
+ ```
24
26
 
25
- A demo is a project pre-configured with jsenv.
26
- The following command can be used to install and try a demo:
27
+ CLI will init jsenv in a directory. It can be a new directory or an existing one.
27
28
 
28
29
  ```console
29
- npm create jsenv@latest
30
+ Welcome in jsenv CLI
31
+ ? Enter a directory: ›
30
32
  ```
31
33
 
32
- It will prompt to choose one of the available demo:
34
+ Then you'll be prompted to select a template.
33
35
 
34
36
  ```console
35
- ? Select a demo: › - Use arrow-keys. Return to submit.
37
+ Enter a directory: › demo
38
+ ? Select a template: › - Use arrow-keys. Return to submit.
36
39
  ❯ web
37
40
  web-components
38
41
  web-react
@@ -40,41 +43,27 @@ It will prompt to choose one of the available demo:
40
43
  node-package
41
44
  ```
42
45
 
43
- Selecting "web" will copy [create-jsenv/demo-web/](./packages/related/create-jsenv/demo-web/) files into a directory:
46
+ A template is a project pre-configured with jsenv.
47
+ Selecting "web" would init [demo-web/](./packages/related/cli/demo-web/):
44
48
 
45
49
  ```console
46
- Select a demo: › web
47
- copy demo files into "[...]jsenv-demo-web/" (done in 0.1 second)
48
- ----- commands to run -----
49
- cd jsenv-demo-web
50
+ Enter a directory: › demo
51
+ Select a template: web
52
+ init jsenv in "[...]/demo/" (done in 0.01 second)
53
+ ----- 2 commands to run -----
54
+ cd demo
50
55
  npm install
51
- npm start
52
- ---------------------------
56
+ -----------------------------
53
57
  ```
54
58
 
55
- After running the suggested commands the demo is ready.
56
-
57
- The demo contains preconfigured scripts:
59
+ The templates have installed scripts:
58
60
 
59
61
  - `npm run dev`: starts a server for source files; Documented in [B) Dev](./docs/users/b_dev/b_dev.md).
60
62
  - `npm run build`: generate build files; Documented in [C) Build](./docs/users/c_build/c_build.md).
61
63
  - `npm run build:serve`: start a server for build files; Documented in [C) Build#how-to-serve-build-files](./docs/users/c_build/c_build.md#3-how-to-serve-build-files).
62
64
  - `npm run test`: execute test files; Documented in [D) Test](./docs/users/d_test/d_test.md).
63
65
 
64
- # CLI
65
-
66
- Jsenv commands to test it quickly.
67
-
68
- | I want to | Command |
69
- | ------------------------------------- | ------------------------ |
70
- | Start a local server for source files | `npx @jsenv/cli dev` |
71
- | Build source files into "./dist/" | `npx @jsenv/cli build` |
72
- | Start a local server for build files | `npx @jsenv/cli preview` |
73
- | Run all test files | `npx @jsenv/cli test` |
74
-
75
- The commands are very basic, for advanced use cases you should use jsenv API.
76
-
77
- For example in order to start a dev server you would rather do `npm run dev` that would be declared in [package.json#scripts.dev](./packages/related/create-jsenv/demo-web/package.json#L8) to execute [scripts/dev.mjs](./packages/related/create-jsenv/demo-web/scripts/dev.mjs).
66
+ <!-- For example in order to start a dev server you would rather do `npm run dev` that would be declared in [package.json#scripts.dev](./packages/related/create-jsenv/demo-web/package.json#L8) to execute [scripts/dev.mjs](./packages/related/create-jsenv/demo-web/scripts/dev.mjs). -->
78
67
 
79
68
  # The best parts
80
69
 
@@ -2092,18 +2092,26 @@ const setUrlFilename = (url, filename) => {
2092
2092
  };
2093
2093
 
2094
2094
  const ensurePathnameTrailingSlash = (url) => {
2095
- const urlObject = new URL(url);
2096
- const { pathname } = urlObject;
2097
- if (pathname.endsWith("/")) {
2098
- return url;
2095
+ if (typeof url === "string") {
2096
+ const urlObject = new URL(url);
2097
+ const { pathname } = urlObject;
2098
+ if (pathname.endsWith("/")) {
2099
+ return url;
2100
+ }
2101
+ let { origin } = urlObject;
2102
+ // origin is "null" for "file://" urls with Node.js
2103
+ if (origin === "null" && urlObject.href.startsWith("file:")) {
2104
+ origin = "file://";
2105
+ }
2106
+ const { search, hash } = urlObject;
2107
+ const urlWithTrailingSlash = `${origin}${pathname}/${search}${hash}`;
2108
+ return urlWithTrailingSlash;
2099
2109
  }
2100
- let { origin } = urlObject;
2101
- // origin is "null" for "file://" urls with Node.js
2102
- if (origin === "null" && urlObject.href.startsWith("file:")) {
2103
- origin = "file://";
2110
+ if (url.pathname.endsWith("/")) {
2111
+ return url;
2104
2112
  }
2105
- const { search, hash } = urlObject;
2106
- return `${origin}${pathname}/${search}${hash}`;
2113
+ url.pathname += "/";
2114
+ return url;
2107
2115
  };
2108
2116
 
2109
2117
  const isFileSystemPath$1 = (value) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.2.0",
3
+ "version": "39.2.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,7 +40,7 @@
40
40
  "./packages/independent/*",
41
41
  "./packages/internal/*",
42
42
  "./packages/related/*",
43
- "./packages/related/create-jsenv/*"
43
+ "./packages/related/cli/*"
44
44
  ],
45
45
  "scripts": {
46
46
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
@@ -57,7 +57,7 @@
57
57
  "prettier": "prettier --write .",
58
58
  "test:ci": "CI=1 npm run test",
59
59
  "test:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/dev_errors_snapshots.test.mjs",
60
- "workspace:test:ci": "CI=1 npm run test:workspace",
60
+ "workspace:test:ci": "CI=1 npm run workspace:test",
61
61
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
62
62
  "certificate:install": "node ./scripts/dev/install_certificate_authority.mjs",
63
63
  "prepublishOnly": "npm run build"
@@ -65,22 +65,22 @@
65
65
  "dependencies": {
66
66
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
67
67
  "@jsenv/abort": "4.3.0",
68
- "@jsenv/ast": "6.2.2",
69
- "@jsenv/filesystem": "4.8.0",
68
+ "@jsenv/ast": "6.2.3",
69
+ "@jsenv/filesystem": "4.8.1",
70
70
  "@jsenv/humanize": "1.2.4",
71
71
  "@jsenv/importmap": "1.2.1",
72
72
  "@jsenv/integrity": "0.0.2",
73
- "@jsenv/js-module-fallback": "1.3.23",
73
+ "@jsenv/js-module-fallback": "1.3.24",
74
74
  "@jsenv/node-esm-resolution": "1.0.2",
75
- "@jsenv/plugin-bundling": "2.6.16",
75
+ "@jsenv/plugin-bundling": "2.6.17",
76
76
  "@jsenv/plugin-minification": "1.5.5",
77
- "@jsenv/plugin-supervisor": "1.5.3",
78
- "@jsenv/plugin-transpilation": "1.4.6",
77
+ "@jsenv/plugin-supervisor": "1.5.4",
78
+ "@jsenv/plugin-transpilation": "1.4.7",
79
79
  "@jsenv/runtime-compat": "1.3.0",
80
80
  "@jsenv/server": "15.2.13",
81
- "@jsenv/sourcemap": "1.2.14",
81
+ "@jsenv/sourcemap": "1.2.15",
82
82
  "@jsenv/url-meta": "8.4.2",
83
- "@jsenv/urls": "2.2.11",
83
+ "@jsenv/urls": "2.3.0",
84
84
  "@jsenv/utils": "2.1.1"
85
85
  },
86
86
  "devDependencies": {