@guanjinke/artifact-client 1.0.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/README.md +165 -0
- package/dist/artifact-client.d.ts +112 -0
- package/dist/artifact-client.d.ts.map +1 -0
- package/dist/artifact-client.js +167 -0
- package/dist/artifact-client.js.map +1 -0
- package/dist/cli/config-manager.d.ts +27 -0
- package/dist/cli/config-manager.d.ts.map +1 -0
- package/dist/cli/config-manager.js +107 -0
- package/dist/cli/config-manager.js.map +1 -0
- package/dist/cli/setup.d.ts +7 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +366 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/azure-provider.d.ts +40 -0
- package/dist/providers/azure-provider.d.ts.map +1 -0
- package/dist/providers/azure-provider.js +336 -0
- package/dist/providers/azure-provider.js.map +1 -0
- package/dist/providers/oss-provider.d.ts +39 -0
- package/dist/providers/oss-provider.d.ts.map +1 -0
- package/dist/providers/oss-provider.js +342 -0
- package/dist/providers/oss-provider.js.map +1 -0
- package/dist/providers/storage-provider.d.ts +50 -0
- package/dist/providers/storage-provider.d.ts.map +1 -0
- package/dist/providers/storage-provider.js +11 -0
- package/dist/providers/storage-provider.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format.d.ts +9 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/semver.d.ts +46 -0
- package/dist/utils/semver.d.ts.map +1 -0
- package/dist/utils/semver.js +112 -0
- package/dist/utils/semver.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @guanjinke/artifact-client
|
|
2
|
+
|
|
3
|
+
Artifact management client and CLI for Azure Blob Storage and Aliyun OSS.
|
|
4
|
+
|
|
5
|
+
Manage plugin build artifacts stored in `plugin_artifacts/` — list plugins, versions, artifacts, upload and download with automatic version tracking.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @guanjinke/artifact-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node.js >= 20.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### As a Library
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ArtifactClient } from '@guanjinke/artifact-client';
|
|
21
|
+
|
|
22
|
+
// Azure Storage
|
|
23
|
+
const azClient = new ArtifactClient('az', {
|
|
24
|
+
sasUrl: 'https://<account>.blob.core.windows.net/<container>?<SAS token>',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Aliyun OSS
|
|
28
|
+
const ossClient = new ArtifactClient('oss', {
|
|
29
|
+
keyId: 'your-access-key-id',
|
|
30
|
+
key: 'your-access-key-secret',
|
|
31
|
+
bucket: 'your-bucket',
|
|
32
|
+
region: 'oss-cn-hangzhou', // optional, defaults to oss-cn-hangzhou
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// List all plugins
|
|
36
|
+
const plugins = await client.listPlugins();
|
|
37
|
+
// [{ name: 'myPlugin', path: 'plugin_artifacts/myPlugin/' }, ...]
|
|
38
|
+
|
|
39
|
+
// List plugins with sizes
|
|
40
|
+
const pluginsWithSize = await client.listPlugins({ includeSize: true });
|
|
41
|
+
|
|
42
|
+
// List major versions of a plugin
|
|
43
|
+
const majors = await client.listMajorVersions('myPlugin');
|
|
44
|
+
// [{ majorVersion: '1.0', latestVersion: '1.0.5', minorCount: 3, path: '...' }, ...]
|
|
45
|
+
|
|
46
|
+
// List major versions sorted ascending
|
|
47
|
+
const majorsAsc = await client.listMajorVersions('myPlugin', { sortOrder: 'asc' });
|
|
48
|
+
|
|
49
|
+
// Get the latest version for a major
|
|
50
|
+
const latest = await client.getLatestVersion('myPlugin', '1.0');
|
|
51
|
+
// { version: '1.0.5', path: 'plugin_artifacts/myPlugin/1.0.5/' }
|
|
52
|
+
|
|
53
|
+
// List all minor versions under a major
|
|
54
|
+
const minors = await client.listMinorVersions('myPlugin', '1.0');
|
|
55
|
+
// [{ version: '1.0.5', path: '...' }, { version: '1.0.4', path: '...' }, ...]
|
|
56
|
+
|
|
57
|
+
// List artifacts in a specific version
|
|
58
|
+
const artifacts = await client.listArtifacts('myPlugin', '1.0.5');
|
|
59
|
+
// [{ name: 'bundle.zip', path: '...', sizeMB: 12.5 }, ...]
|
|
60
|
+
|
|
61
|
+
// Upload an artifact
|
|
62
|
+
await client.uploadArtifact('myPlugin', '1.0.6', 'bundle.zip', './dist/bundle.zip');
|
|
63
|
+
|
|
64
|
+
// Download by full path
|
|
65
|
+
await client.downloadArtifactByPath(
|
|
66
|
+
'plugin_artifacts/myPlugin/1.0.5/bundle.zip',
|
|
67
|
+
'./downloads'
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Download by name
|
|
71
|
+
await client.downloadArtifact('myPlugin', '1.0.5', 'bundle.zip', './downloads');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### As a CLI
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Login (saves credentials to ~/.afm/config.json)
|
|
78
|
+
afm az login --sasurl "https://..."
|
|
79
|
+
afm oss login --keyid "your-id" --key "your-key" --bucket "my-bucket"
|
|
80
|
+
|
|
81
|
+
# Or pass credentials inline
|
|
82
|
+
afm az list-plugins --sasurl "https://..."
|
|
83
|
+
|
|
84
|
+
# List plugins
|
|
85
|
+
afm az list-plugins
|
|
86
|
+
afm az list-plugins --size
|
|
87
|
+
|
|
88
|
+
# List major versions
|
|
89
|
+
afm az list-majors myPlugin
|
|
90
|
+
afm az list-majors myPlugin --size --sort asc
|
|
91
|
+
|
|
92
|
+
# Get latest version for a major
|
|
93
|
+
afm az get-latest myPlugin 1.0
|
|
94
|
+
|
|
95
|
+
# List minor versions
|
|
96
|
+
afm az list-minors myPlugin 1.0
|
|
97
|
+
afm az list-minors myPlugin 1.0 --sort asc
|
|
98
|
+
|
|
99
|
+
# List artifacts in a version
|
|
100
|
+
afm az list-artifacts myPlugin 1.0.5
|
|
101
|
+
afm az list-artifacts myPlugin 1.0.5 --size
|
|
102
|
+
|
|
103
|
+
# Upload
|
|
104
|
+
afm az upload myPlugin 1.0.6 bundle.zip ./dist/bundle.zip
|
|
105
|
+
|
|
106
|
+
# Download by full path
|
|
107
|
+
afm az download --path "plugin_artifacts/myPlugin/1.0.5/bundle.zip" --out ./downloads
|
|
108
|
+
|
|
109
|
+
# Download by name
|
|
110
|
+
afm az download --plugin myPlugin --version 1.0.5 --file bundle.zip --out ./downloads
|
|
111
|
+
|
|
112
|
+
# Manage config
|
|
113
|
+
afm az config show
|
|
114
|
+
afm az config clear
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### OSS Commands
|
|
118
|
+
|
|
119
|
+
Same as above, replace `az` with `oss`:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
afm oss list-plugins --keyid "id" --key "secret"
|
|
123
|
+
afm oss upload myPlugin 1.0.6 bundle.zip ./dist/bundle.zip
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Storage Layout
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
<container/bucket>/
|
|
130
|
+
└── plugin_artifacts/
|
|
131
|
+
├── pluginA/
|
|
132
|
+
│ ├── version1.0.txt # Tracks latest 1.0.x version
|
|
133
|
+
│ ├── version2.0.txt # Tracks latest 2.0.x version
|
|
134
|
+
│ ├── versiondev.txt # Tracks latest dev (0.0.x) version
|
|
135
|
+
│ ├── 1.0.5/
|
|
136
|
+
│ │ ├── bundle.zip
|
|
137
|
+
│ │ └── checksum.txt
|
|
138
|
+
│ └── 1.0.6/
|
|
139
|
+
│ └── bundle.zip
|
|
140
|
+
└── pluginB/
|
|
141
|
+
└── ...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- **Version files** (`version{major.minor}.txt`, `versiondev.txt`): track the latest full version
|
|
145
|
+
- Azure: latest version stored in blob metadata (`latestversion`)
|
|
146
|
+
- OSS: latest version stored in object tag (`latestversion`)
|
|
147
|
+
|
|
148
|
+
## API Reference
|
|
149
|
+
|
|
150
|
+
### `ArtifactClient`
|
|
151
|
+
|
|
152
|
+
| Method | Description |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `listPlugins(opts?)` | List all plugins |
|
|
155
|
+
| `listMajorVersions(plugin, opts?)` | List major versions with latest version and count |
|
|
156
|
+
| `getLatestVersion(plugin, major, opts?)` | Get latest minor version for a major |
|
|
157
|
+
| `listMinorVersions(plugin, major, opts?)` | List all minor versions under a major |
|
|
158
|
+
| `listArtifacts(plugin, version, opts?)` | List all artifact files in a version |
|
|
159
|
+
| `uploadArtifact(plugin, version, name, localPath)` | Upload a file and update version tracking |
|
|
160
|
+
| `downloadArtifactByPath(fullPath, localDir)` | Download by full storage path |
|
|
161
|
+
| `downloadArtifact(plugin, version, fileName, localDir)` | Download by name |
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { StorageType, AzureConfig, OSSConfig, PluginInfo, MajorVersionInfo, VersionInfo, ArtifactInfo, ListOptions, GetLatestOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Artifact Client.
|
|
4
|
+
*
|
|
5
|
+
* Provides a unified API for managing artifacts across Azure Storage and Aliyun OSS.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { ArtifactClient } from '@guanjinke/artifact-client';
|
|
10
|
+
*
|
|
11
|
+
* // For Azure Storage
|
|
12
|
+
* const client = new ArtifactClient('az', { sasUrl: 'https://...' });
|
|
13
|
+
*
|
|
14
|
+
* // For Aliyun OSS
|
|
15
|
+
* const client = new ArtifactClient('oss', {
|
|
16
|
+
* keyId: 'your-key-id',
|
|
17
|
+
* key: 'your-key-secret',
|
|
18
|
+
* bucket: 'your-bucket',
|
|
19
|
+
* region: 'oss-cn-hangzhou',
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* const plugins = await client.listPlugins();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class ArtifactClient {
|
|
26
|
+
private provider;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new ArtifactClient.
|
|
29
|
+
*
|
|
30
|
+
* @param type - The storage type: 'az' for Azure, 'oss' for Aliyun OSS.
|
|
31
|
+
* @param config - Storage-specific configuration.
|
|
32
|
+
*/
|
|
33
|
+
constructor(type: StorageType, config: AzureConfig | OSSConfig);
|
|
34
|
+
/**
|
|
35
|
+
* List all plugins under the plugin_artifacts/ root directory.
|
|
36
|
+
*
|
|
37
|
+
* @param options.includeSize - Whether to calculate total storage size per plugin (in MB).
|
|
38
|
+
* @returns Array of plugin info.
|
|
39
|
+
*/
|
|
40
|
+
listPlugins(options?: {
|
|
41
|
+
includeSize?: boolean;
|
|
42
|
+
}): Promise<PluginInfo[]>;
|
|
43
|
+
/**
|
|
44
|
+
* List all major versions (Major.Minor) for a given plugin.
|
|
45
|
+
*
|
|
46
|
+
* @param pluginName - The plugin name.
|
|
47
|
+
* @param options.sortOrder - Sort order for the major versions (default: 'desc').
|
|
48
|
+
* @param options.includeSize - Whether to include total storage size per major (in MB).
|
|
49
|
+
* @returns Array of major version info, including latest version and minor count.
|
|
50
|
+
*/
|
|
51
|
+
listMajorVersions(pluginName: string, options?: ListOptions): Promise<MajorVersionInfo[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the latest minor (patch) version for a given major version.
|
|
54
|
+
* Useful for cross-cloud synchronization detection.
|
|
55
|
+
*
|
|
56
|
+
* @param pluginName - The plugin name.
|
|
57
|
+
* @param majorVersion - The major version (e.g., "1.0", "dev").
|
|
58
|
+
* @param options.includeSize - Whether to include total storage size (in MB).
|
|
59
|
+
* @returns The latest version info.
|
|
60
|
+
*/
|
|
61
|
+
getLatestVersion(pluginName: string, majorVersion: string, options?: GetLatestOptions): Promise<VersionInfo>;
|
|
62
|
+
/**
|
|
63
|
+
* List all minor (patch) versions under a specific major version.
|
|
64
|
+
*
|
|
65
|
+
* @param pluginName - The plugin name.
|
|
66
|
+
* @param majorVersion - The major version (e.g., "1.0", "dev").
|
|
67
|
+
* @param options.sortOrder - Sort order (default: 'desc', newest first).
|
|
68
|
+
* @param options.includeSize - Whether to include storage size per version (in MB).
|
|
69
|
+
* @returns Array of version info sorted by semver.
|
|
70
|
+
*/
|
|
71
|
+
listMinorVersions(pluginName: string, majorVersion: string, options?: ListOptions): Promise<VersionInfo[]>;
|
|
72
|
+
/**
|
|
73
|
+
* List all artifacts for a specific version of a plugin.
|
|
74
|
+
*
|
|
75
|
+
* @param pluginName - The plugin name.
|
|
76
|
+
* @param version - The full semantic version (e.g., "1.0.5").
|
|
77
|
+
* @param options.includeSize - Whether to include file sizes (in MB).
|
|
78
|
+
* @returns Array of artifact info.
|
|
79
|
+
*/
|
|
80
|
+
listArtifacts(pluginName: string, version: string, options?: {
|
|
81
|
+
includeSize?: boolean;
|
|
82
|
+
}): Promise<ArtifactInfo[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Upload a local file as an artifact to a specific plugin version directory.
|
|
85
|
+
* Automatically updates the latestversion metadata/tag on the version file.
|
|
86
|
+
*
|
|
87
|
+
* @param pluginName - The plugin name.
|
|
88
|
+
* @param version - The target version (e.g., "1.0.5").
|
|
89
|
+
* @param artifactName - The file name to use in the version directory.
|
|
90
|
+
* @param localFilePath - The local file path to upload.
|
|
91
|
+
*/
|
|
92
|
+
uploadArtifact(pluginName: string, version: string, artifactName: string, localFilePath: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Download an artifact using its full storage path.
|
|
95
|
+
*
|
|
96
|
+
* @param fullPath - The full path on the storage (e.g., "plugin_artifacts/foo/1.0.5/bar.zip").
|
|
97
|
+
* @param localDir - The local directory to save the file to.
|
|
98
|
+
*/
|
|
99
|
+
downloadArtifactByPath(fullPath: string, localDir: string): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Download an artifact by plugin name, version, and file name.
|
|
102
|
+
* The full path is constructed as: plugin_artifacts/{plugin}/{version}/{fileName}
|
|
103
|
+
*
|
|
104
|
+
* @param pluginName - The plugin name.
|
|
105
|
+
* @param version - The version (e.g., "1.0.5").
|
|
106
|
+
* @param fileName - The artifact file name.
|
|
107
|
+
* @param localDir - The local directory to save the file to.
|
|
108
|
+
*/
|
|
109
|
+
downloadArtifact(pluginName: string, version: string, fileName: string, localDir: string): Promise<void>;
|
|
110
|
+
private createProvider;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=artifact-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-client.d.ts","sourceRoot":"","sources":["../src/artifact-client.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAkB;IAElC;;;;;OAKG;gBACS,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS;IAQ9D;;;;;OAKG;IACG,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAQ7E;;;;;;;OAOG;IACG,iBAAiB,CACrB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQ9B;;;;;;;;OAQG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,CAAC;IAQvB;;;;;;;;OAQG;IACG,iBAAiB,CACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,WAAW,EAAE,CAAC;IAQzB;;;;;;;OAOG;IACG,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAClC,OAAO,CAAC,YAAY,EAAE,CAAC;IAQ1B;;;;;;;;OAQG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;OAKG;IACG,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/E;;;;;;;;OAQG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAQhB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArtifactClient = void 0;
|
|
4
|
+
const azure_provider_1 = require("./providers/azure-provider");
|
|
5
|
+
const oss_provider_1 = require("./providers/oss-provider");
|
|
6
|
+
/**
|
|
7
|
+
* Artifact Client.
|
|
8
|
+
*
|
|
9
|
+
* Provides a unified API for managing artifacts across Azure Storage and Aliyun OSS.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { ArtifactClient } from '@guanjinke/artifact-client';
|
|
14
|
+
*
|
|
15
|
+
* // For Azure Storage
|
|
16
|
+
* const client = new ArtifactClient('az', { sasUrl: 'https://...' });
|
|
17
|
+
*
|
|
18
|
+
* // For Aliyun OSS
|
|
19
|
+
* const client = new ArtifactClient('oss', {
|
|
20
|
+
* keyId: 'your-key-id',
|
|
21
|
+
* key: 'your-key-secret',
|
|
22
|
+
* bucket: 'your-bucket',
|
|
23
|
+
* region: 'oss-cn-hangzhou',
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const plugins = await client.listPlugins();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class ArtifactClient {
|
|
30
|
+
provider;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new ArtifactClient.
|
|
33
|
+
*
|
|
34
|
+
* @param type - The storage type: 'az' for Azure, 'oss' for Aliyun OSS.
|
|
35
|
+
* @param config - Storage-specific configuration.
|
|
36
|
+
*/
|
|
37
|
+
constructor(type, config) {
|
|
38
|
+
this.provider = this.createProvider(type, config);
|
|
39
|
+
}
|
|
40
|
+
// ============================================================
|
|
41
|
+
// listPlugins
|
|
42
|
+
// ============================================================
|
|
43
|
+
/**
|
|
44
|
+
* List all plugins under the plugin_artifacts/ root directory.
|
|
45
|
+
*
|
|
46
|
+
* @param options.includeSize - Whether to calculate total storage size per plugin (in MB).
|
|
47
|
+
* @returns Array of plugin info.
|
|
48
|
+
*/
|
|
49
|
+
async listPlugins(options) {
|
|
50
|
+
return this.provider.listPlugins(options);
|
|
51
|
+
}
|
|
52
|
+
// ============================================================
|
|
53
|
+
// listMajorVersions
|
|
54
|
+
// ============================================================
|
|
55
|
+
/**
|
|
56
|
+
* List all major versions (Major.Minor) for a given plugin.
|
|
57
|
+
*
|
|
58
|
+
* @param pluginName - The plugin name.
|
|
59
|
+
* @param options.sortOrder - Sort order for the major versions (default: 'desc').
|
|
60
|
+
* @param options.includeSize - Whether to include total storage size per major (in MB).
|
|
61
|
+
* @returns Array of major version info, including latest version and minor count.
|
|
62
|
+
*/
|
|
63
|
+
async listMajorVersions(pluginName, options) {
|
|
64
|
+
return this.provider.listMajorVersions(pluginName, options);
|
|
65
|
+
}
|
|
66
|
+
// ============================================================
|
|
67
|
+
// getLatestVersion
|
|
68
|
+
// ============================================================
|
|
69
|
+
/**
|
|
70
|
+
* Get the latest minor (patch) version for a given major version.
|
|
71
|
+
* Useful for cross-cloud synchronization detection.
|
|
72
|
+
*
|
|
73
|
+
* @param pluginName - The plugin name.
|
|
74
|
+
* @param majorVersion - The major version (e.g., "1.0", "dev").
|
|
75
|
+
* @param options.includeSize - Whether to include total storage size (in MB).
|
|
76
|
+
* @returns The latest version info.
|
|
77
|
+
*/
|
|
78
|
+
async getLatestVersion(pluginName, majorVersion, options) {
|
|
79
|
+
return this.provider.getLatestVersion(pluginName, majorVersion, options);
|
|
80
|
+
}
|
|
81
|
+
// ============================================================
|
|
82
|
+
// listMinorVersions
|
|
83
|
+
// ============================================================
|
|
84
|
+
/**
|
|
85
|
+
* List all minor (patch) versions under a specific major version.
|
|
86
|
+
*
|
|
87
|
+
* @param pluginName - The plugin name.
|
|
88
|
+
* @param majorVersion - The major version (e.g., "1.0", "dev").
|
|
89
|
+
* @param options.sortOrder - Sort order (default: 'desc', newest first).
|
|
90
|
+
* @param options.includeSize - Whether to include storage size per version (in MB).
|
|
91
|
+
* @returns Array of version info sorted by semver.
|
|
92
|
+
*/
|
|
93
|
+
async listMinorVersions(pluginName, majorVersion, options) {
|
|
94
|
+
return this.provider.listMinorVersions(pluginName, majorVersion, options);
|
|
95
|
+
}
|
|
96
|
+
// ============================================================
|
|
97
|
+
// listArtifacts
|
|
98
|
+
// ============================================================
|
|
99
|
+
/**
|
|
100
|
+
* List all artifacts for a specific version of a plugin.
|
|
101
|
+
*
|
|
102
|
+
* @param pluginName - The plugin name.
|
|
103
|
+
* @param version - The full semantic version (e.g., "1.0.5").
|
|
104
|
+
* @param options.includeSize - Whether to include file sizes (in MB).
|
|
105
|
+
* @returns Array of artifact info.
|
|
106
|
+
*/
|
|
107
|
+
async listArtifacts(pluginName, version, options) {
|
|
108
|
+
return this.provider.listArtifacts(pluginName, version, options);
|
|
109
|
+
}
|
|
110
|
+
// ============================================================
|
|
111
|
+
// uploadArtifact
|
|
112
|
+
// ============================================================
|
|
113
|
+
/**
|
|
114
|
+
* Upload a local file as an artifact to a specific plugin version directory.
|
|
115
|
+
* Automatically updates the latestversion metadata/tag on the version file.
|
|
116
|
+
*
|
|
117
|
+
* @param pluginName - The plugin name.
|
|
118
|
+
* @param version - The target version (e.g., "1.0.5").
|
|
119
|
+
* @param artifactName - The file name to use in the version directory.
|
|
120
|
+
* @param localFilePath - The local file path to upload.
|
|
121
|
+
*/
|
|
122
|
+
async uploadArtifact(pluginName, version, artifactName, localFilePath) {
|
|
123
|
+
return this.provider.uploadArtifact(pluginName, version, artifactName, localFilePath);
|
|
124
|
+
}
|
|
125
|
+
// ============================================================
|
|
126
|
+
// downloadArtifactByPath
|
|
127
|
+
// ============================================================
|
|
128
|
+
/**
|
|
129
|
+
* Download an artifact using its full storage path.
|
|
130
|
+
*
|
|
131
|
+
* @param fullPath - The full path on the storage (e.g., "plugin_artifacts/foo/1.0.5/bar.zip").
|
|
132
|
+
* @param localDir - The local directory to save the file to.
|
|
133
|
+
*/
|
|
134
|
+
async downloadArtifactByPath(fullPath, localDir) {
|
|
135
|
+
return this.provider.downloadArtifactByPath(fullPath, localDir);
|
|
136
|
+
}
|
|
137
|
+
// ============================================================
|
|
138
|
+
// downloadArtifact
|
|
139
|
+
// ============================================================
|
|
140
|
+
/**
|
|
141
|
+
* Download an artifact by plugin name, version, and file name.
|
|
142
|
+
* The full path is constructed as: plugin_artifacts/{plugin}/{version}/{fileName}
|
|
143
|
+
*
|
|
144
|
+
* @param pluginName - The plugin name.
|
|
145
|
+
* @param version - The version (e.g., "1.0.5").
|
|
146
|
+
* @param fileName - The artifact file name.
|
|
147
|
+
* @param localDir - The local directory to save the file to.
|
|
148
|
+
*/
|
|
149
|
+
async downloadArtifact(pluginName, version, fileName, localDir) {
|
|
150
|
+
return this.provider.downloadArtifact(pluginName, version, fileName, localDir);
|
|
151
|
+
}
|
|
152
|
+
// ============================================================
|
|
153
|
+
// Private
|
|
154
|
+
// ============================================================
|
|
155
|
+
createProvider(type, config) {
|
|
156
|
+
switch (type) {
|
|
157
|
+
case 'az':
|
|
158
|
+
return new azure_provider_1.AzureProvider(config);
|
|
159
|
+
case 'oss':
|
|
160
|
+
return new oss_provider_1.OSSProvider(config);
|
|
161
|
+
default:
|
|
162
|
+
throw new Error(`Unknown storage type: ${type}. Use 'az' or 'oss'.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.ArtifactClient = ArtifactClient;
|
|
167
|
+
//# sourceMappingURL=artifact-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-client.js","sourceRoot":"","sources":["../src/artifact-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CLIConfig, AzureConfig, OSSConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Read the full CLI config from ~/.afm/config.json.
|
|
4
|
+
* Returns an empty object if the file does not exist.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readConfig(): CLIConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Write the full CLI config to ~/.afm/config.json.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeConfig(config: CLIConfig): void;
|
|
11
|
+
/**
|
|
12
|
+
* Save Azure authentication config.
|
|
13
|
+
*/
|
|
14
|
+
export declare function saveAzureConfig(config: AzureConfig): void;
|
|
15
|
+
/**
|
|
16
|
+
* Save OSS authentication config.
|
|
17
|
+
*/
|
|
18
|
+
export declare function saveOSSConfig(config: OSSConfig): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get the config file path for display purposes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getConfigPath(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Clear all stored configuration.
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearConfig(): void;
|
|
27
|
+
//# sourceMappingURL=config-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../../src/cli/config-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAc7D;;;GAGG;AACH,wBAAgB,UAAU,IAAI,SAAS,CAUtC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAGnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAIzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAIrD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readConfig = readConfig;
|
|
37
|
+
exports.writeConfig = writeConfig;
|
|
38
|
+
exports.saveAzureConfig = saveAzureConfig;
|
|
39
|
+
exports.saveOSSConfig = saveOSSConfig;
|
|
40
|
+
exports.getConfigPath = getConfigPath;
|
|
41
|
+
exports.clearConfig = clearConfig;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const CONFIG_DIR = path.join(os.homedir(), '.afm');
|
|
46
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
47
|
+
/**
|
|
48
|
+
* Ensure the config directory exists.
|
|
49
|
+
*/
|
|
50
|
+
function ensureConfigDir() {
|
|
51
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
52
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Read the full CLI config from ~/.afm/config.json.
|
|
57
|
+
* Returns an empty object if the file does not exist.
|
|
58
|
+
*/
|
|
59
|
+
function readConfig() {
|
|
60
|
+
try {
|
|
61
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
const raw = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
65
|
+
return JSON.parse(raw);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Write the full CLI config to ~/.afm/config.json.
|
|
73
|
+
*/
|
|
74
|
+
function writeConfig(config) {
|
|
75
|
+
ensureConfigDir();
|
|
76
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Save Azure authentication config.
|
|
80
|
+
*/
|
|
81
|
+
function saveAzureConfig(config) {
|
|
82
|
+
const current = readConfig();
|
|
83
|
+
current.az = config;
|
|
84
|
+
writeConfig(current);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Save OSS authentication config.
|
|
88
|
+
*/
|
|
89
|
+
function saveOSSConfig(config) {
|
|
90
|
+
const current = readConfig();
|
|
91
|
+
current.oss = config;
|
|
92
|
+
writeConfig(current);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the config file path for display purposes.
|
|
96
|
+
*/
|
|
97
|
+
function getConfigPath() {
|
|
98
|
+
return CONFIG_FILE;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Clear all stored configuration.
|
|
102
|
+
*/
|
|
103
|
+
function clearConfig() {
|
|
104
|
+
ensureConfigDir();
|
|
105
|
+
writeConfig({});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=config-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-manager.js","sourceRoot":"","sources":["../../src/cli/config-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gCAUC;AAKD,kCAGC;AAKD,0CAIC;AAKD,sCAIC;AAKD,sCAEC;AAKD,kCAGC;AAxED,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAGzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEzD;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU;IACxB,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAc,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAiB;IAC3C,eAAe,EAAE,CAAC;IAClB,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAmB;IACjD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC;IACpB,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAiB;IAC7C,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC;IACrB,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,eAAe,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA+BvC"}
|