verdaccio-stats 0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Xingwang Liao
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 ADDED
@@ -0,0 +1,67 @@
1
+ # Verdaccio Stats Plugin
2
+
3
+ This plugin adds detailed statistics functionality to your Verdaccio private npm registry.
4
+
5
+ ## Features
6
+
7
+ - Track package download statistics
8
+ - Track manifest view counts
9
+ - ISO week format support
10
+ - Admin interface to view statistics
11
+
12
+ ## Installation
13
+
14
+ Install Globally
15
+
16
+ ```bash
17
+ npm install -g verdaccio-stats
18
+ ```
19
+
20
+ Or install to verdaccio plugin folder:
21
+
22
+ ```bash
23
+ mkdir -p ./install-here/
24
+ npm install --global-style \
25
+ --bin-links=false --save=false --package-lock=false \
26
+ --omit=dev --omit=optional --omit=peer \
27
+ --prefix ./install-here/ \
28
+ verdaccio-stats@latest
29
+ mv ./install-here/node_modules/verdaccio-stats/ /path/to/verdaccio/plugins/
30
+ ```
31
+
32
+
33
+ ## Configuration
34
+
35
+ Add the plugin to your Verdaccio config file:
36
+
37
+ ```yaml
38
+ middlewares:
39
+ verdaccio-stats:
40
+ file: ./stats.db # Optional, SQLite database
41
+ iso-week: false # Optional, whether to use ISO week format
42
+ count-downloads: true # Optional, whether to count downloads
43
+ count-manifest-views: true # Optional, whether to count manifest views
44
+ ```
45
+
46
+ ### Configuration Options
47
+
48
+ | Option | Type | Default | Description |
49
+ |--------|------|---------|-------------|
50
+ | `file` | string | `stats.db` | Path to the file where stats are stored |
51
+ | `iso-week` | boolean | `false` | Whether to use ISO week format |
52
+ | `count-downloads` | boolean | `true` | Whether to count downloads |
53
+ | `count-manifest-views` | boolean | `true` | Whether to count manifest views |
54
+
55
+ ## Usage
56
+
57
+ After installing and configuring the plugin, it will automatically begin collecting the specified statistics. The data will be stored in the configured database file.
58
+
59
+ You can view the statistics by visiting the following URL:
60
+
61
+ ```
62
+ http://your-registry.com/-/verdaccio/stats/admin
63
+ ```
64
+
65
+ ## License
66
+
67
+ See the [`LICENSE`](LICENSE ) file for details.
@@ -0,0 +1,40 @@
1
+ import type { Config } from "@verdaccio/types";
2
+ import z from "zod";
3
+ declare const statsConfig: z.ZodObject<{
4
+ file: z.ZodOptional<z.ZodString>;
5
+ "iso-week": z.ZodOptional<z.ZodBoolean>;
6
+ "count-downloads": z.ZodOptional<z.ZodBoolean>;
7
+ "count-manifest-views": z.ZodOptional<z.ZodBoolean>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ file?: string | undefined;
10
+ "iso-week"?: boolean | undefined;
11
+ "count-downloads"?: boolean | undefined;
12
+ "count-manifest-views"?: boolean | undefined;
13
+ }, {
14
+ file?: string | undefined;
15
+ "iso-week"?: boolean | undefined;
16
+ "count-downloads"?: boolean | undefined;
17
+ "count-manifest-views"?: boolean | undefined;
18
+ }>;
19
+ export interface ConfigHolder {
20
+ countDownloads: boolean;
21
+ countManifestViews: boolean;
22
+ file: string;
23
+ isoWeek: boolean;
24
+ logo?: string;
25
+ title: string;
26
+ }
27
+ export type StatsConfig = z.infer<typeof statsConfig>;
28
+ export declare class ParsedPluginConfig implements ConfigHolder {
29
+ private readonly config;
30
+ private readonly verdaccioConfig;
31
+ get configPath(): string;
32
+ get countDownloads(): boolean;
33
+ get countManifestViews(): boolean;
34
+ get file(): string;
35
+ get isoWeek(): boolean;
36
+ get logo(): string | undefined;
37
+ get title(): string;
38
+ constructor(config: StatsConfig, verdaccioConfig: Config);
39
+ }
40
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare const plugin: {
2
+ name: string;
3
+ version: string;
4
+ };
5
+ export declare const pluginKey: string;
6
+ export declare const UNIVERSE_PACKAGE_NAME = "**";
7
+ export declare const UNIVERSE_PACKAGE_VERSION = "*";
8
+ export declare const PERIOD_TYPES: readonly ["overall", "daily", "monthly", "weekly", "yearly"];
9
+ export declare const PERIOD_VALUE_TOTAL = "total";
10
+ export declare const DEFAULT_SQLITE_FILE = "stats.db";
11
+ export declare const API_BASE_PATH = "/-/verdaccio/stats";
@@ -0,0 +1,4 @@
1
+ import type { UmzugOptions } from "umzug";
2
+ import buildDebug from "debug";
3
+ export declare const debug: buildDebug.Debugger;
4
+ export declare function getUmzugLogger(): UmzugOptions["logger"];
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { Plugin as default } from "./plugin";