@clerc/plugin-update-notifier 0.0.1 → 1.1.0
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/LICENSE +21 -0
- package/README.md +5 -39
- package/dist/index.d.mts +43 -0
- package/dist/index.mjs +41 -0
- package/package.json +49 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Ray <https://github.com/so1ve>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
# @clerc/plugin-update-notifier
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@clerc/plugin-update-notifier)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Documenation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Read the [documentation](https://clerc.so1ve.dev/official-plugins/plugin-update-notifier.html) for more details.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 📝 License
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@clerc/plugin-update-notifier`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|
|
11
|
+
[MIT](../../LICENSE). Made with ❤️ by [Ray](https://github.com/so1ve)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "@clerc/core";
|
|
2
|
+
import { NotifyOptions, Settings, UpdateNotifier } from "update-notifier";
|
|
3
|
+
import { PartialRequired } from "@clerc/utils";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
type CustomMessage = string | ((notifier: UpdateNotifier) => string);
|
|
7
|
+
type EnhancedNotifierSettings = PartialRequired<Settings, "pkg">;
|
|
8
|
+
type EnhancedNotifyOptions = Omit<NotifyOptions, "message"> & {
|
|
9
|
+
message?: CustomMessage;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/index.d.ts
|
|
13
|
+
interface UpdateNotifierPluginOptions extends EnhancedNotifierSettings {
|
|
14
|
+
notify?: EnhancedNotifyOptions;
|
|
15
|
+
}
|
|
16
|
+
declare module "@clerc/core" {
|
|
17
|
+
interface ContextStore {
|
|
18
|
+
/**
|
|
19
|
+
* The update-notifier instance, available if plugin-update-notifier is
|
|
20
|
+
* used.
|
|
21
|
+
*/
|
|
22
|
+
updateNotifier?: UpdateNotifier;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Plugin to check for CLI updates using update-notifier.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { Clerc } from "@clerc/core";
|
|
32
|
+
* import { updateNotifierPlugin } from "@clerc/plugin-update-notifier";
|
|
33
|
+
* import pkg from "./package.json";
|
|
34
|
+
*
|
|
35
|
+
* Clerc.create().use(updateNotifierPlugin({ pkg })).parse();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const updateNotifierPlugin: ({
|
|
39
|
+
notify: notifySettings,
|
|
40
|
+
...notifierSettings
|
|
41
|
+
}: UpdateNotifierPluginOptions) => Plugin;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { UpdateNotifierPluginOptions, updateNotifierPlugin };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { definePlugin } from "@clerc/core";
|
|
2
|
+
import updateNotifier from "update-notifier";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Plugin to check for CLI updates using update-notifier.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Clerc } from "@clerc/core";
|
|
12
|
+
* import { updateNotifierPlugin } from "@clerc/plugin-update-notifier";
|
|
13
|
+
* import pkg from "./package.json";
|
|
14
|
+
*
|
|
15
|
+
* Clerc.create().use(updateNotifierPlugin({ pkg })).parse();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
const updateNotifierPlugin = ({ notify: notifySettings, ...notifierSettings }) => definePlugin({ setup: (cli) => {
|
|
19
|
+
const notifier = updateNotifier(notifierSettings);
|
|
20
|
+
cli.store.updateNotifier = notifier;
|
|
21
|
+
cli.interceptor({
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
handler: async (ctx, next) => {
|
|
24
|
+
showNotification(notifier, notifySettings);
|
|
25
|
+
await next();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} });
|
|
29
|
+
function showNotification(notifier, notifySettings) {
|
|
30
|
+
if (notifier.update) {
|
|
31
|
+
if (typeof notifySettings?.message === "function") notifySettings.message = notifySettings.message(notifier);
|
|
32
|
+
notifier.notify({
|
|
33
|
+
defer: false,
|
|
34
|
+
...notifySettings,
|
|
35
|
+
message: notifySettings?.message
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { updateNotifierPlugin };
|
package/package.json
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-update-notifier",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Clerc plugin for checking CLI updates",
|
|
5
7
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"args",
|
|
9
|
+
"arguments",
|
|
10
|
+
"argv",
|
|
11
|
+
"clerc",
|
|
12
|
+
"clerc-plugin",
|
|
13
|
+
"cli",
|
|
14
|
+
"terminal",
|
|
15
|
+
"update",
|
|
16
|
+
"notifier"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/clercjs/clerc/tree/main/packages/plugin-update-notifier#readme",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/clercjs/clerc.git",
|
|
22
|
+
"directory": "/"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/clercjs/clerc/issues"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.mjs",
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.mjs",
|
|
34
|
+
"module": "./dist/index.mjs",
|
|
35
|
+
"types": "./dist/index.d.mts",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"update-notifier": "^7.3.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/update-notifier": "^6.0.8",
|
|
47
|
+
"@clerc/core": "1.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@clerc/core": "*"
|
|
51
|
+
}
|
|
52
|
+
}
|