@open-xchange/vite-plugin-replace-pkg 0.0.1 → 0.0.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
- ## [0.0.1] - 2024-08-06
3
+ ## [0.0.2] - 2024-08-07
4
+
5
+ - changed: GitLab API token as plugin parameter instead of env var
6
+
7
+ ## [0.0.1] - 2024-08-07
4
8
 
5
9
  - initial release
package/README.md CHANGED
@@ -105,6 +105,7 @@ The location of the source file to resolve the module imports with. There are di
105
105
  | Name | Type | Default | Description |
106
106
  | - | - | - | - |
107
107
  | `server` | `string` | _required_ | The URL of the GitLab server to be used for downloading the source file. |
108
+ | `token` | `string\|undefined` | _required_ | A valid GitLab API access token. If the token does not exist or is empty, downloading the source wile will be skipped silently. |
108
109
  | `project` | `string\|number` | _required_ | Name or numeric identifier of the GitLab project. The project name may contain slashes (e.g. `"my-group/my-project"`) which will be encoded internally. |
109
110
  | `path` | `string` | _required_ | Path to the source file to be downloaded. Slashes in the path will be encoded internally. |
110
111
  | `ref` | `string` | `HEAD` | The name of a branch or tag, or a commit ID. Slashes in branch names will be encoded internally. |
@@ -177,3 +178,7 @@ export default defineConfig(() => {
177
178
  ],
178
179
  })
179
180
  ```
181
+
182
+ ### Logging
183
+
184
+ By default, warning messages and error messages will be logged to the shell. The environment variable `PLUGIN_REPLACE_PKG_LOGLEVEL` can be used to change the log level of this plugin. Possible values are `info`, `warn`, `error`, and `silent`.
package/dist/index.d.ts CHANGED
@@ -16,16 +16,17 @@ export interface VitePluginReplacePkg_RequestInit extends RequestInit {
16
16
  }
17
17
  /**
18
18
  * The specification of a source file in a GitLab repository.
19
- *
20
- * Downloading the source file needs a valid GitLab API token stored in the
21
- * environment variable "GITLAB_TOKEN". If the variable does not exist,
22
- * downloading the source wile will be skipped.
23
19
  */
24
20
  export interface VitePluginReplacePkg_GitLabFile {
25
21
  /**
26
22
  * The URL of the GitLab server to be used for downloading the source file.
27
23
  */
28
24
  server: string;
25
+ /**
26
+ * A valid GitLab API access token. If the token does not exist or is an
27
+ * empty string, downloading the source wile will be skipped silently.
28
+ */
29
+ token: string | undefined;
29
30
  /**
30
31
  * Name or identifier of the GitLab project (repository). The project name
31
32
  * may contain slashes (e.g. "my-group/my-project") which will be encoded
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { Logger } from "@open-xchange/vite-helper/logger";
4
4
  export const PROJECT_NAME = "@open-xchange/vite-plugin-replace-pkg";
5
5
  const logger = new Logger({
6
6
  loggerPrefix: "pkg",
7
- logLevelEnvVar: "PLUGIN_REPLACE_PACKAGES_LOGLEVEL",
7
+ logLevelEnvVar: "PLUGIN_REPLACE_PKG_LOGLEVEL",
8
8
  });
9
9
  // functions ==================================================================
10
10
  const resolveFetchOptions = (options) => {
@@ -23,10 +23,9 @@ const resolveFetchOptions = (options) => {
23
23
  }
24
24
  // `GitLabFile` object
25
25
  if ("project" in replace) {
26
- // resolve GitLab API tokens
27
- const token = process.env.GITLAB_TOKEN;
28
- if (!token) {
29
- logger.warn("missing environment variable %f with GitLab API token", "GITLAB_TOKEN");
26
+ // GitLab API token
27
+ if (!replace.token) {
28
+ logger.warn("missing GitLab API token");
30
29
  return;
31
30
  }
32
31
  // build the file URL for the GitLab API
@@ -39,7 +38,7 @@ const resolveFetchOptions = (options) => {
39
38
  if (replace.ref) {
40
39
  query.ref = replace.ref;
41
40
  }
42
- const headers = { "PRIVATE-TOKEN": token };
41
+ const headers = { "PRIVATE-TOKEN": replace.token };
43
42
  return { url, headers, query };
44
43
  }
45
44
  logger.error("invalid configuration for package %f", options.package);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/vite-plugin-replace-pkg",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Vite plugin replacing a specific external package with an arbitrary source code module",
5
5
  "repository": {
6
6
  "url": "https://gitlab.open-xchange.com/fspd/npm-packages/vite-plugin-replace-pkg"