@initx-plugin/manager 0.0.3 → 0.0.4

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/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ declare class PluginManagerPlugin extends InitxPlugin {
5
5
  matching: string;
6
6
  description: string;
7
7
  }[];
8
- handle(_ctx: InitxContext, type: string, ...others: string[]): Promise<void>;
8
+ handle(context: InitxContext, type: string, ...others: string[]): Promise<void>;
9
9
  }
10
10
 
11
11
  export { PluginManagerPlugin as default };
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ declare class PluginManagerPlugin extends InitxPlugin {
5
5
  matching: string;
6
6
  description: string;
7
7
  }[];
8
- handle(_ctx: InitxContext, type: string, ...others: string[]): Promise<void>;
8
+ handle(context: InitxContext, type: string, ...others: string[]): Promise<void>;
9
9
  }
10
10
 
11
11
  export { PluginManagerPlugin as default };
package/dist/index.mjs CHANGED
@@ -177,12 +177,18 @@ async function removePlugin(targetName) {
177
177
  log.success(`Removed ${nameColor(removePlugin2.name)}`);
178
178
  }
179
179
 
180
- async function updatePlugin() {
181
- const excludedPlugins = await fetchExcludedPlugins();
182
- const fetchedPlugins = await fetchPlugins();
180
+ async function updatePlugin(options) {
181
+ const includeDev = options.dev || false;
182
+ const [developmentPlugins, fetchedPlugins] = await loadingFunction(
183
+ "Fetching plugins",
184
+ () => Promise.all([
185
+ fetchDevelopmentPlugins(),
186
+ fetchPlugins()
187
+ ])
188
+ );
183
189
  const pluginNames = [];
184
190
  const pluginRootMap = fetchedPlugins.reduce((acc, { name, root }) => {
185
- if (excludedPlugins.includes(name)) {
191
+ if (!includeDev && developmentPlugins.includes(name)) {
186
192
  return acc;
187
193
  }
188
194
  pluginNames.push(name);
@@ -194,13 +200,19 @@ async function updatePlugin() {
194
200
  Object.keys(pluginRootMap).forEach((name) => {
195
201
  const packageInfo = fs.readJsonSync(path.join(pluginRootMap[name], "package.json"));
196
202
  const pluginInfo = searchPluginsInfo.find((plugin) => plugin.name === name);
197
- if (!pluginInfo || packageInfo.version === pluginInfo.version) {
203
+ if (!pluginInfo) {
204
+ return;
205
+ }
206
+ const isDevelopmentPlugin = developmentPlugins.includes(name);
207
+ const condition = isDevelopmentPlugin ? !includeDev : packageInfo.version === pluginInfo.version;
208
+ if (condition) {
198
209
  return;
199
210
  }
200
211
  needUpdatePlugins.push({
201
212
  name,
202
213
  version: packageInfo.version,
203
- target: pluginInfo.version
214
+ target: pluginInfo.version,
215
+ isDev: isDevelopmentPlugin
204
216
  });
205
217
  });
206
218
  if (needUpdatePlugins.length === 0) {
@@ -208,9 +220,11 @@ async function updatePlugin() {
208
220
  return;
209
221
  }
210
222
  log.info("Need update plugins:");
211
- needUpdatePlugins.forEach(({ name, version, target }) => {
212
- console.log(`${nameColor(name)} ${dim(gray(`${version} ->`))} ${target}`);
213
- });
223
+ console.log(columnify(needUpdatePlugins.map(({ name, version, target, isDev }) => ({
224
+ name: nameColor(name),
225
+ version: dim(gray(`${isDev ? "[dev] " : ""}${version}`)),
226
+ target
227
+ }))));
214
228
  const confirm = await inquirer.confirm("Do you want to update these plugins?");
215
229
  if (!confirm) {
216
230
  log.warn("Update canceled");
@@ -223,35 +237,26 @@ async function updatePlugin() {
223
237
  );
224
238
  log.success(`Plugins updated: ${displayNames}`);
225
239
  }
226
- async function fetchExcludedPlugins() {
240
+ async function fetchDevelopmentPlugins() {
227
241
  const npmListResult = await c("npm", ["list", "-g", "--depth=0"]);
228
- const excludedPlugins = [];
242
+ const pluginNames = [];
229
243
  npmListResult.content.split(/\r?\n/).forEach((line) => {
230
244
  const metched = /(?:@initx-plugin\/|initx-plugin-)[^@]+/.exec(line);
231
245
  if (metched && line.includes("->")) {
232
- excludedPlugins.push(metched[0]);
246
+ pluginNames.push(metched[0]);
233
247
  }
234
248
  });
235
- return excludedPlugins;
249
+ return pluginNames;
236
250
  }
237
251
 
238
- var __defProp = Object.defineProperty;
239
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
240
- var __publicField = (obj, key, value) => {
241
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
242
- return value;
243
- };
244
252
  class PluginManagerPlugin extends InitxPlugin {
245
- constructor() {
246
- super(...arguments);
247
- __publicField(this, "matchers", [
248
- {
249
- matching: "plugin",
250
- description: "Plugin Manager"
251
- }
252
- ]);
253
- }
254
- async handle(_ctx, type, ...others) {
253
+ matchers = [
254
+ {
255
+ matching: "plugin",
256
+ description: "Plugin Manager"
257
+ }
258
+ ];
259
+ async handle(context, type, ...others) {
255
260
  const [name] = others;
256
261
  switch (type) {
257
262
  case "list": {
@@ -263,7 +268,7 @@ class PluginManagerPlugin extends InitxPlugin {
263
268
  break;
264
269
  }
265
270
  case "update": {
266
- await updatePlugin();
271
+ await updatePlugin(context.cliOptions);
267
272
  break;
268
273
  }
269
274
  case "remove": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/manager",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "initx plugin manager",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -24,8 +24,8 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@initx-plugin/core": "^0.0.25",
28
- "@initx-plugin/utils": "^0.0.25",
27
+ "@initx-plugin/core": "^0.0.27",
28
+ "@initx-plugin/utils": "^0.0.27",
29
29
  "columnify": "^1.6.0",
30
30
  "fs-extra": "^11.2.0",
31
31
  "picocolors": "^1.1.1"
@@ -34,13 +34,13 @@
34
34
  "@imba97/eslint-config": "^0.0.5",
35
35
  "@types/columnify": "^1.5.4",
36
36
  "@types/fs-extra": "^11.0.4",
37
- "@types/node": "^22.9.0",
38
- "bumpp": "^9.8.1",
39
- "eslint": "^9.14.0",
40
- "lint-staged": "^15.2.10",
37
+ "@types/node": "^22.10.2",
38
+ "bumpp": "^9.9.2",
39
+ "eslint": "^9.17.0",
40
+ "lint-staged": "^15.3.0",
41
41
  "simple-git-hooks": "^2.11.1",
42
- "typescript": "^5.6.3",
43
- "unbuild": "^2.0.0"
42
+ "typescript": "^5.7.2",
43
+ "unbuild": "^3.1.0"
44
44
  },
45
45
  "simple-git-hooks": {
46
46
  "pre-commit": "pnpm lint-staged"