@configjs/cli 1.1.7 → 1.1.9

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.
@@ -0,0 +1,157 @@
1
+ // src/utils/logger.ts
2
+ import pc from "picocolors";
3
+ var Logger = class {
4
+ level = 1 /* INFO */;
5
+ setLevel(level) {
6
+ this.level = level;
7
+ }
8
+ debug(message, ...args) {
9
+ if (this.level <= 0 /* DEBUG */) {
10
+ console.log(pc.gray(`[DEBUG] ${message}`), ...args);
11
+ }
12
+ }
13
+ info(message, ...args) {
14
+ if (this.level <= 1 /* INFO */) {
15
+ console.log(pc.cyan(`\u2139 ${message}`), ...args);
16
+ }
17
+ }
18
+ success(message, ...args) {
19
+ if (this.level <= 1 /* INFO */) {
20
+ console.log(pc.green(`\u2713 ${message}`), ...args);
21
+ }
22
+ }
23
+ warn(message, ...args) {
24
+ if (this.level <= 2 /* WARN */) {
25
+ console.warn(pc.yellow(`\u26A0\uFE0F ${message}`), ...args);
26
+ }
27
+ }
28
+ error(message, ...args) {
29
+ if (this.level <= 3 /* ERROR */) {
30
+ console.error(pc.red(`\u2716 ${message}`), ...args);
31
+ }
32
+ }
33
+ header(message) {
34
+ if (this.level <= 1 /* INFO */) {
35
+ console.log();
36
+ console.log(pc.bold(pc.magenta(`\u25C6 ${message}`)));
37
+ console.log();
38
+ }
39
+ }
40
+ section(title) {
41
+ if (this.level <= 1 /* INFO */) {
42
+ console.log();
43
+ console.log(pc.bold(pc.cyan(`\u25B8 ${title}`)));
44
+ }
45
+ }
46
+ item(message, color = "gray") {
47
+ if (this.level <= 1 /* INFO */) {
48
+ const colorFn = pc[color];
49
+ console.log(colorFn(` \u2022 ${message}`));
50
+ }
51
+ }
52
+ dim(message) {
53
+ if (this.level <= 1 /* INFO */) {
54
+ console.log(pc.gray(` ${message}`));
55
+ }
56
+ }
57
+ step(message) {
58
+ if (this.level <= 1 /* INFO */) {
59
+ console.log(pc.cyan(`
60
+ \u2192 ${message}`));
61
+ }
62
+ }
63
+ box(title, content) {
64
+ if (this.level <= 1 /* INFO */) {
65
+ const maxLength = Math.max(
66
+ title.length,
67
+ ...content.map((line) => line.length)
68
+ );
69
+ const border = "\u2500".repeat(maxLength + 4);
70
+ console.log(pc.cyan(`\u250C${border}\u2510`));
71
+ console.log(pc.cyan(`\u2502 ${title.padEnd(maxLength)} \u2502`));
72
+ console.log(pc.cyan(`\u251C${border}\u2524`));
73
+ content.forEach((line) => {
74
+ console.log(pc.cyan(`\u2502 ${line.padEnd(maxLength)} \u2502`));
75
+ });
76
+ console.log(pc.cyan(`\u2514${border}\u2518`));
77
+ }
78
+ }
79
+ };
80
+ var logger = new Logger();
81
+
82
+ // src/utils/logger-provider.ts
83
+ var NoOpLogger = class {
84
+ debug() {
85
+ }
86
+ info() {
87
+ }
88
+ warn() {
89
+ }
90
+ error() {
91
+ }
92
+ success() {
93
+ }
94
+ header() {
95
+ }
96
+ section() {
97
+ }
98
+ item() {
99
+ }
100
+ dim() {
101
+ }
102
+ step() {
103
+ }
104
+ box() {
105
+ }
106
+ };
107
+ var LoggerProvider = class {
108
+ currentLogger = new NoOpLogger();
109
+ /**
110
+ * Get the current logger instance
111
+ * CLI commands should use the real logger
112
+ * Core modules should use whatever is provided
113
+ */
114
+ getLogger() {
115
+ return this.currentLogger;
116
+ }
117
+ /**
118
+ * Set the active logger (typically called by CLI)
119
+ * @param newLogger - The logger instance to use
120
+ */
121
+ setLogger(newLogger) {
122
+ this.currentLogger = newLogger;
123
+ }
124
+ /**
125
+ * Enable CLI logging (use the real logger)
126
+ */
127
+ enableCLILogging() {
128
+ this.currentLogger = logger;
129
+ }
130
+ /**
131
+ * Disable logging (use no-op logger)
132
+ */
133
+ disableLogging() {
134
+ this.currentLogger = new NoOpLogger();
135
+ }
136
+ /**
137
+ * Set the log level for the real logger
138
+ */
139
+ setLogLevel(level) {
140
+ if (this.currentLogger === logger) {
141
+ logger.setLevel(level);
142
+ }
143
+ }
144
+ };
145
+ var loggerProvider = new LoggerProvider();
146
+ function getModuleLogger() {
147
+ return loggerProvider.getLogger();
148
+ }
149
+ function initializeCLILogging() {
150
+ loggerProvider.enableCLILogging();
151
+ }
152
+
153
+ export {
154
+ logger,
155
+ getModuleLogger,
156
+ initializeCLILogging
157
+ };
@@ -1,21 +1,24 @@
1
1
  import {
2
2
  detectPackageManager
3
- } from "./chunk-MQV3WNMH.js";
3
+ } from "./chunk-6GV4NKUX.js";
4
4
  import {
5
5
  checkPathExists,
6
6
  createDefaultFsAdapter,
7
- logger,
8
7
  readFileContent,
9
8
  readPackageJson,
10
9
  readTsConfig,
11
10
  writeFileContent
12
- } from "./chunk-HM2JWJOO.js";
11
+ } from "./chunk-FIB2J36N.js";
12
+ import {
13
+ getModuleLogger
14
+ } from "./chunk-QPEUT7QG.js";
13
15
 
14
16
  // src/core/plugin-tracker.ts
15
17
  import { join } from "path";
16
18
  var CONFIG_FILE_NAME = ".configjsrc";
17
19
  var CONFIG_VERSION = "1.0.0";
18
20
  var PluginTracker = class {
21
+ logger = getModuleLogger();
19
22
  configPath;
20
23
  config = null;
21
24
  fsAdapter;
@@ -44,12 +47,12 @@ var PluginTracker = class {
44
47
  );
45
48
  this.config = JSON.parse(content);
46
49
  if (!this.config.version) {
47
- logger.warn("Old config format detected, migrating...");
50
+ this.logger.warn("Old config format detected, migrating...");
48
51
  this.config.version = CONFIG_VERSION;
49
52
  await this.save();
50
53
  }
51
54
  } catch (error) {
52
- logger.error("Failed to load plugin configuration", error);
55
+ this.logger.error("Failed to load plugin configuration", error);
53
56
  this.config = {
54
57
  version: CONFIG_VERSION,
55
58
  installedPlugins: [],
@@ -69,7 +72,7 @@ var PluginTracker = class {
69
72
  const content = JSON.stringify(this.config, null, 2);
70
73
  await writeFileContent(this.configPath, content, "utf-8", this.fsAdapter);
71
74
  } catch (error) {
72
- logger.error("Failed to save plugin configuration", error);
75
+ this.logger.error("Failed to save plugin configuration", error);
73
76
  throw error;
74
77
  }
75
78
  }
@@ -114,7 +117,7 @@ var PluginTracker = class {
114
117
  throw new Error("Configuration not loaded");
115
118
  }
116
119
  if (this.isInstalled(plugin.name)) {
117
- logger.warn(`Plugin ${plugin.name} is already marked as installed`);
120
+ this.logger.warn(`Plugin ${plugin.name} is already marked as installed`);
118
121
  return;
119
122
  }
120
123
  const installedPlugin = {
@@ -123,7 +126,7 @@ var PluginTracker = class {
123
126
  };
124
127
  this.config.installedPlugins.push(installedPlugin);
125
128
  await this.save();
126
- logger.debug(`Marked plugin ${plugin.name} as installed`);
129
+ this.logger.debug(`Marked plugin ${plugin.name} as installed`);
127
130
  }
128
131
  /**
129
132
  * Supprime un plugin de la liste des installés
@@ -136,12 +139,12 @@ var PluginTracker = class {
136
139
  (p) => p.name === pluginName
137
140
  );
138
141
  if (index === -1) {
139
- logger.warn(`Plugin ${pluginName} not found in installed plugins`);
142
+ this.logger.warn(`Plugin ${pluginName} not found in installed plugins`);
140
143
  return;
141
144
  }
142
145
  this.config.installedPlugins.splice(index, 1);
143
146
  await this.save();
144
- logger.debug(`Removed plugin ${pluginName} from installed plugins`);
147
+ this.logger.debug(`Removed plugin ${pluginName} from installed plugins`);
145
148
  }
146
149
  /**
147
150
  * Met à jour les informations d'un plugin installé
@@ -158,7 +161,7 @@ var PluginTracker = class {
158
161
  }
159
162
  Object.assign(plugin, updates);
160
163
  await this.save();
161
- logger.debug(`Updated plugin ${pluginName}`);
164
+ this.logger.debug(`Updated plugin ${pluginName}`);
162
165
  }
163
166
  /**
164
167
  * Efface toute la configuration
@@ -170,7 +173,7 @@ var PluginTracker = class {
170
173
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
171
174
  };
172
175
  await this.save();
173
- logger.info("Reset plugin configuration");
176
+ this.logger.info("Reset plugin configuration");
174
177
  }
175
178
  /**
176
179
  * Vérifie les conflits potentiels avec un nouveau plugin
@@ -400,14 +403,20 @@ async function detectVueApi(projectRoot, srcDir, fsAdapter) {
400
403
  await findVueFiles(srcPath);
401
404
  let hasCompositionApi = false;
402
405
  let hasOptionsApi = false;
406
+ const scriptBlockRegex = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
403
407
  for (const file of files.slice(0, 10)) {
404
408
  try {
405
409
  const content = await adapter.readFile(file, "utf-8");
406
- if (content.includes("<script setup>") || content.includes('<script setup lang="ts">') || content.includes("export default defineComponent") || content.includes("setup()")) {
407
- hasCompositionApi = true;
408
- }
409
- if (content.includes("export default {") || content.includes("export default{")) {
410
- hasOptionsApi = true;
410
+ let match;
411
+ while ((match = scriptBlockRegex.exec(content)) !== null) {
412
+ const attrs = match[1] || "";
413
+ const scriptContent = match[2] || "";
414
+ if (attrs.includes("setup") || scriptContent.includes("setup(") || scriptContent.includes("defineComponent(")) {
415
+ hasCompositionApi = true;
416
+ }
417
+ if (scriptContent.includes("export default {") || scriptContent.includes("export default{")) {
418
+ hasOptionsApi = true;
419
+ }
411
420
  }
412
421
  } catch {
413
422
  }
@@ -450,6 +459,7 @@ async function detectLockfile(projectRoot, packageManager, fsAdapter) {
450
459
  }
451
460
  return lockfile;
452
461
  }
462
+ var logger = getModuleLogger();
453
463
  async function detectContext(projectRoot, fsAdapter) {
454
464
  const fullPath = resolve(projectRoot);
455
465
  if (detectionCache.has(fullPath)) {
@@ -482,7 +492,7 @@ async function detectContext(projectRoot, fsAdapter) {
482
492
  Promise.resolve(detectFramework(pkg)),
483
493
  detectTypeScript(fullPath, fsAdapter),
484
494
  detectBundler(fullPath, pkg, fsAdapter),
485
- detectPackageManager(fullPath),
495
+ detectPackageManager(fullPath, fsAdapter),
486
496
  detectSrcDir(fullPath, fsAdapter),
487
497
  detectPublicDir(fullPath, fsAdapter),
488
498
  detectGit(fullPath, fsAdapter)
package/dist/cli.js CHANGED
@@ -1,19 +1,23 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ initializeCLILogging
4
+ } from "./chunk-QPEUT7QG.js";
2
5
  import "./chunk-QGM4M3NI.js";
3
6
 
4
7
  // src/cli.ts
5
8
  import { Command } from "commander";
6
9
 
7
10
  // package.json
8
- var version = "1.1.7";
11
+ var version = "1.1.9";
9
12
 
10
13
  // src/cli.ts
14
+ initializeCLILogging();
11
15
  var program = new Command();
12
16
  program.name("confjs").description("Configure your frontend stack, instantly").version(version);
13
17
  program.command("react").description("Configure a React project").option("-y, --yes", "Accept all defaults").option("-d, --dry-run", "Simulate without writing to disk").option("-s, --silent", "Non-interactive mode").option("--debug", "Enable debug logs").option("-c, --config <file>", "Use configuration file").option("-f, --force", "Force installation (overwrite configs)").option("--no-install", "Generate configs only, skip package installation").action(
14
18
  async (options) => {
15
19
  try {
16
- const { ReactCommand } = await import("./react-command-3WUUJZBW.js");
20
+ const { ReactCommand } = await import("./react-command-NHCD2L7R.js");
17
21
  const command = new ReactCommand();
18
22
  await command.execute(options);
19
23
  } catch (error) {
@@ -25,7 +29,7 @@ program.command("react").description("Configure a React project").option("-y, --
25
29
  program.command("nextjs").description("Configure a Next.js project").option("-y, --yes", "Accept all defaults").option("-d, --dry-run", "Simulate without writing to disk").option("-s, --silent", "Non-interactive mode").option("--debug", "Enable debug logs").option("-c, --config <file>", "Use configuration file").option("-f, --force", "Force installation (overwrite configs)").option("--no-install", "Generate configs only, skip package installation").action(
26
30
  async (options) => {
27
31
  try {
28
- const { NextjsCommand } = await import("./nextjs-command-LA245VK4.js");
32
+ const { NextjsCommand } = await import("./nextjs-command-W53FZE7U.js");
29
33
  const command = new NextjsCommand();
30
34
  await command.execute(options);
31
35
  } catch (error) {
@@ -37,7 +41,7 @@ program.command("nextjs").description("Configure a Next.js project").option("-y,
37
41
  program.command("vue").description("Configure a Vue.js project").option("-y, --yes", "Accept all defaults").option("-d, --dry-run", "Simulate without writing to disk").option("-s, --silent", "Non-interactive mode").option("--debug", "Enable debug logs").option("-c, --config <file>", "Use configuration file").option("-f, --force", "Force installation (overwrite configs)").option("--no-install", "Generate configs only, skip package installation").action(
38
42
  async (options) => {
39
43
  try {
40
- const { VueCommand } = await import("./vue-command-WPFTD5JM.js");
44
+ const { VueCommand } = await import("./vue-command-GYKDHJRJ.js");
41
45
  const command = new VueCommand();
42
46
  await command.execute(options);
43
47
  } catch (error) {
@@ -48,7 +52,7 @@ program.command("vue").description("Configure a Vue.js project").option("-y, --y
48
52
  );
49
53
  program.command("list").description("List available libraries").option("-c, --category <category>", "Filter by category").action(async (options) => {
50
54
  try {
51
- const { listLibraries } = await import("./list-GGH3SFER.js");
55
+ const { listLibraries } = await import("./list-TDMIAZPQ.js");
52
56
  listLibraries(options);
53
57
  } catch (error) {
54
58
  console.error("Error:", error);
@@ -57,7 +61,7 @@ program.command("list").description("List available libraries").option("-c, --ca
57
61
  });
58
62
  program.command("check").description("Check compatibility without installing").option("-c, --config <file>", "Configuration file to check").action(async (options) => {
59
63
  try {
60
- const { checkCompatibility } = await import("./check-QX4VFU73.js");
64
+ const { checkCompatibility } = await import("./check-IOMRDWLB.js");
61
65
  await checkCompatibility(options);
62
66
  } catch (error) {
63
67
  console.error("Error:", error);
@@ -66,7 +70,7 @@ program.command("check").description("Check compatibility without installing").o
66
70
  });
67
71
  program.command("installed").description("List installed plugins").action(async () => {
68
72
  try {
69
- const { installedCommand } = await import("./installed-WA6I2IFD.js");
73
+ const { installedCommand } = await import("./installed-LZE6LH7A.js");
70
74
  await installedCommand();
71
75
  } catch (error) {
72
76
  console.error("Error:", error);
@@ -75,7 +79,7 @@ program.command("installed").description("List installed plugins").action(async
75
79
  });
76
80
  program.command("remove <plugin>").description("Remove an installed plugin").action(async (plugin) => {
77
81
  try {
78
- const { removeCommand } = await import("./remove-JBICRDXX.js");
82
+ const { removeCommand } = await import("./remove-XQBB4NC3.js");
79
83
  await removeCommand(plugin);
80
84
  } catch (error) {
81
85
  console.error("Error:", error);
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  PluginTracker,
3
3
  detectContext
4
- } from "./chunk-TVZWTKJU.js";
5
- import "./chunk-MQV3WNMH.js";
4
+ } from "./chunk-WHV4KF4U.js";
5
+ import "./chunk-6GV4NKUX.js";
6
+ import "./chunk-FIB2J36N.js";
6
7
  import {
7
8
  logger
8
- } from "./chunk-HM2JWJOO.js";
9
+ } from "./chunk-QPEUT7QG.js";
9
10
  import "./chunk-QGM4M3NI.js";
10
11
 
11
12
  // src/cli/commands/installed.ts
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  pluginRegistry
3
- } from "./chunk-HKNOLXCV.js";
4
- import "./chunk-MQV3WNMH.js";
5
- import "./chunk-HM2JWJOO.js";
3
+ } from "./chunk-6WWDHX4E.js";
4
+ import "./chunk-6GV4NKUX.js";
5
+ import "./chunk-FIB2J36N.js";
6
+ import "./chunk-QPEUT7QG.js";
6
7
  import "./chunk-QGM4M3NI.js";
7
8
 
8
9
  // src/cli/commands/list.ts
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  BaseFrameworkCommand,
3
3
  getFrameworkMetadata
4
- } from "./chunk-GVI6UQX2.js";
5
- import "./chunk-NLTJ6GYH.js";
6
- import "./chunk-HKNOLXCV.js";
4
+ } from "./chunk-ABHFQM5U.js";
5
+ import "./chunk-ATUTE7PE.js";
6
+ import "./chunk-6WWDHX4E.js";
7
7
  import {
8
8
  DetectionError,
9
9
  detectContext
10
- } from "./chunk-TVZWTKJU.js";
11
- import "./chunk-MQV3WNMH.js";
12
- import "./chunk-HM2JWJOO.js";
10
+ } from "./chunk-WHV4KF4U.js";
11
+ import "./chunk-6GV4NKUX.js";
12
+ import "./chunk-FIB2J36N.js";
13
+ import "./chunk-QPEUT7QG.js";
13
14
  import {
14
15
  getTranslations
15
16
  } from "./chunk-QBMH2K7B.js";
@@ -1,7 +1,9 @@
1
1
  import {
2
- checkPathExists,
2
+ checkPathExists
3
+ } from "./chunk-FIB2J36N.js";
4
+ import {
3
5
  logger
4
- } from "./chunk-HM2JWJOO.js";
6
+ } from "./chunk-QPEUT7QG.js";
5
7
  import {
6
8
  getTranslations
7
9
  } from "./chunk-QBMH2K7B.js";
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  BaseFrameworkCommand,
3
3
  getFrameworkMetadata
4
- } from "./chunk-GVI6UQX2.js";
5
- import "./chunk-NLTJ6GYH.js";
6
- import "./chunk-HKNOLXCV.js";
4
+ } from "./chunk-ABHFQM5U.js";
5
+ import "./chunk-ATUTE7PE.js";
6
+ import "./chunk-6WWDHX4E.js";
7
7
  import {
8
8
  DetectionError,
9
9
  detectContext
10
- } from "./chunk-TVZWTKJU.js";
11
- import "./chunk-MQV3WNMH.js";
12
- import "./chunk-HM2JWJOO.js";
10
+ } from "./chunk-WHV4KF4U.js";
11
+ import "./chunk-6GV4NKUX.js";
12
+ import "./chunk-FIB2J36N.js";
13
+ import "./chunk-QPEUT7QG.js";
13
14
  import {
14
15
  getTranslations
15
16
  } from "./chunk-QBMH2K7B.js";
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  PluginTracker,
3
3
  detectContext
4
- } from "./chunk-TVZWTKJU.js";
5
- import "./chunk-MQV3WNMH.js";
4
+ } from "./chunk-WHV4KF4U.js";
5
+ import "./chunk-6GV4NKUX.js";
6
+ import "./chunk-FIB2J36N.js";
6
7
  import {
7
8
  logger
8
- } from "./chunk-HM2JWJOO.js";
9
+ } from "./chunk-QPEUT7QG.js";
9
10
  import {
10
11
  __commonJS,
11
12
  __require,
@@ -1,7 +1,9 @@
1
1
  import {
2
- checkPathExists,
2
+ checkPathExists
3
+ } from "./chunk-FIB2J36N.js";
4
+ import {
3
5
  logger
4
- } from "./chunk-HM2JWJOO.js";
6
+ } from "./chunk-QPEUT7QG.js";
5
7
  import {
6
8
  getTranslations
7
9
  } from "./chunk-QBMH2K7B.js";
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  BaseFrameworkCommand,
3
3
  getFrameworkMetadata
4
- } from "./chunk-GVI6UQX2.js";
5
- import "./chunk-NLTJ6GYH.js";
6
- import "./chunk-HKNOLXCV.js";
4
+ } from "./chunk-ABHFQM5U.js";
5
+ import "./chunk-ATUTE7PE.js";
6
+ import "./chunk-6WWDHX4E.js";
7
7
  import {
8
8
  DetectionError,
9
9
  detectContext
10
- } from "./chunk-TVZWTKJU.js";
11
- import "./chunk-MQV3WNMH.js";
12
- import "./chunk-HM2JWJOO.js";
10
+ } from "./chunk-WHV4KF4U.js";
11
+ import "./chunk-6GV4NKUX.js";
12
+ import "./chunk-FIB2J36N.js";
13
+ import "./chunk-QPEUT7QG.js";
13
14
  import {
14
15
  getTranslations
15
16
  } from "./chunk-QBMH2K7B.js";
@@ -1,7 +1,9 @@
1
1
  import {
2
- checkPathExists,
2
+ checkPathExists
3
+ } from "./chunk-FIB2J36N.js";
4
+ import {
3
5
  logger
4
- } from "./chunk-HM2JWJOO.js";
6
+ } from "./chunk-QPEUT7QG.js";
5
7
  import {
6
8
  getTranslations
7
9
  } from "./chunk-QBMH2K7B.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configjs/cli",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "type": "module",
5
5
  "description": "Configure your frontend stack, instantly - Utilitaire CLI d'installation modulaire de bibliothèques frontend",
6
6
  "keywords": [