@happlyui/cli 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -187196,16 +187196,17 @@ function resolveAlias(alias, config) {
187196
187196
  }
187197
187197
  function getComponentPath(componentName, componentType, config) {
187198
187198
  const ext = config.tsx ? ".tsx" : ".jsx";
187199
+ const srcPrefix = config.srcDir ? "src/" : "";
187199
187200
  switch (componentType) {
187200
187201
  case "registry:ui":
187201
187202
  case "registry:component":
187202
- return path2.join(config.aliases.ui.replace("@/", ""), `${componentName}${ext}`);
187203
+ return path2.join(srcPrefix + config.aliases.ui.replace("@/", ""), `${componentName}${ext}`);
187203
187204
  case "registry:hook":
187204
- return path2.join((config.aliases.hooks || "@/hooks").replace("@/", ""), `${componentName}${ext}`);
187205
+ return path2.join(srcPrefix + (config.aliases.hooks || "@/hooks").replace("@/", ""), `${componentName}${ext}`);
187205
187206
  case "registry:lib":
187206
- return path2.join((config.aliases.lib || "@/lib").replace("@/", ""), `${componentName}${ext}`);
187207
+ return path2.join(srcPrefix + (config.aliases.lib || "@/lib").replace("@/", ""), `${componentName}${ext}`);
187207
187208
  default:
187208
- return path2.join(config.aliases.ui.replace("@/", ""), `${componentName}${ext}`);
187209
+ return path2.join(srcPrefix + config.aliases.ui.replace("@/", ""), `${componentName}${ext}`);
187209
187210
  }
187210
187211
  }
187211
187212
  async function ensureDir(dirPath) {
@@ -188906,6 +188907,68 @@ function getInstallCommand(packageManager, packages, dev) {
188906
188907
  }
188907
188908
  }
188908
188909
 
188910
+ // src/utils/env.ts
188911
+ function isNonInteractive() {
188912
+ if (isAIAgent()) {
188913
+ return true;
188914
+ }
188915
+ if (isCI()) {
188916
+ return true;
188917
+ }
188918
+ if (!process.stdin.isTTY) {
188919
+ return true;
188920
+ }
188921
+ return false;
188922
+ }
188923
+ function isAIAgent() {
188924
+ const env2 = process.env;
188925
+ if (env2.CLAUDECODE === "1" || env2.CLAUDE_CODE_ENTRYPOINT) {
188926
+ return true;
188927
+ }
188928
+ if (env2.CURSOR_TRACE_ID || env2.CURSOR_EDITOR) {
188929
+ return true;
188930
+ }
188931
+ if (env2.GITHUB_COPILOT_CLI) {
188932
+ return true;
188933
+ }
188934
+ if (env2.AIDER_MODEL || env2.AIDER) {
188935
+ return true;
188936
+ }
188937
+ if (env2.CODEIUM_API_KEY || env2.WINDSURF_EDITOR) {
188938
+ return true;
188939
+ }
188940
+ if (env2.AWS_TOOLKIT_TELEMETRY_OPTOUT !== undefined && env2.VSCODE_PID) {
188941
+ return true;
188942
+ }
188943
+ if (env2.AI_AGENT || env2.AI_ASSISTANT || env2.CODING_AGENT) {
188944
+ return true;
188945
+ }
188946
+ return false;
188947
+ }
188948
+ function isCI() {
188949
+ const env2 = process.env;
188950
+ return !!(env2.CI || env2.CONTINUOUS_INTEGRATION || env2.GITHUB_ACTIONS || env2.GITLAB_CI || env2.CIRCLECI || env2.TRAVIS || env2.JENKINS_URL || env2.BUILDKITE || env2.DRONE || env2.CODEBUILD_BUILD_ID || env2.TF_BUILD);
188951
+ }
188952
+ function getAgentName() {
188953
+ const env2 = process.env;
188954
+ if (env2.CLAUDECODE === "1" || env2.CLAUDE_CODE_ENTRYPOINT) {
188955
+ return "Claude Code";
188956
+ }
188957
+ if (env2.CURSOR_TRACE_ID || env2.CURSOR_EDITOR) {
188958
+ return "Cursor";
188959
+ }
188960
+ if (env2.GITHUB_COPILOT_CLI) {
188961
+ return "GitHub Copilot";
188962
+ }
188963
+ if (env2.AIDER_MODEL || env2.AIDER) {
188964
+ return "Aider";
188965
+ }
188966
+ if (env2.CODEIUM_API_KEY || env2.WINDSURF_EDITOR) {
188967
+ return "Windsurf/Codeium";
188968
+ }
188969
+ return null;
188970
+ }
188971
+
188909
188972
  // src/commands/init.ts
188910
188973
  init_types();
188911
188974
  var UTILS_TEMPLATE = `import { type ClassValue, clsx } from "clsx";
@@ -188984,10 +189047,18 @@ var CSS_TEMPLATE = `@tailwind base;
188984
189047
  `;
188985
189048
  async function init(options) {
188986
189049
  const cwd = options.cwd || process.cwd();
189050
+ const nonInteractive = isNonInteractive();
189051
+ const agentName = getAgentName();
189052
+ const useDefaults = options.defaults || options.yes || nonInteractive;
188987
189053
  logger.break();
188988
189054
  logger.log(logger.bold("HapplyUI") + " - Initialize your project");
189055
+ if (agentName) {
189056
+ logger.info(`Detected: ${logger.highlight(agentName)} (using defaults)`);
189057
+ } else if (nonInteractive && !options.yes) {
189058
+ logger.info("Non-interactive mode detected (using defaults)");
189059
+ }
188989
189060
  logger.break();
188990
- if (isInitialized(cwd) && !options.yes) {
189061
+ if (isInitialized(cwd) && !useDefaults) {
188991
189062
  const { overwrite } = await import_prompts.default({
188992
189063
  type: "confirm",
188993
189064
  name: "overwrite",
@@ -189010,8 +189081,14 @@ async function init(options) {
189010
189081
  }
189011
189082
  logger.break();
189012
189083
  let config;
189013
- if (options.defaults || options.yes) {
189084
+ if (useDefaults) {
189014
189085
  config = createDefaultConfig(projectInfo);
189086
+ if (options.baseColor && BASE_COLORS.includes(options.baseColor)) {
189087
+ config.tailwind.baseColor = options.baseColor;
189088
+ }
189089
+ if (options.cssVariables === false) {
189090
+ config.tailwind.cssVariables = false;
189091
+ }
189015
189092
  } else {
189016
189093
  const responses = await import_prompts.default([
189017
189094
  {
@@ -189053,7 +189130,8 @@ async function init(options) {
189053
189130
  try {
189054
189131
  await writeConfig(cwd, config);
189055
189132
  writeSpinner.text = "Created components.json";
189056
- const utilsPath = config.aliases.utils.replace("@/", "");
189133
+ const srcPrefix = config.srcDir ? "src/" : "";
189134
+ const utilsPath = srcPrefix + config.aliases.utils.replace("@/", "");
189057
189135
  const utilsContent = config.tsx ? UTILS_TEMPLATE : UTILS_JS_TEMPLATE;
189058
189136
  const utilsExt = config.tsx ? ".ts" : ".js";
189059
189137
  await writeComponentFile(cwd, `${utilsPath}${utilsExt}`, utilsContent);
@@ -189101,6 +189179,7 @@ function createDefaultConfig(projectInfo) {
189101
189179
  const isSrcDir = projectInfo.isSrcDir;
189102
189180
  return {
189103
189181
  $schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/components.json",
189182
+ srcDir: isSrcDir,
189104
189183
  tailwind: {
189105
189184
  config: projectInfo.tailwindConfig || "tailwind.config.ts",
189106
189185
  css: projectInfo.tailwindCss || (isSrcDir ? "src/index.css" : "index.css"),
@@ -189120,6 +189199,7 @@ function createDefaultConfig(projectInfo) {
189120
189199
  function createConfig(projectInfo, responses) {
189121
189200
  return {
189122
189201
  $schema: "https://cdn.jsdelivr.net/gh/Mindful-Connect/happly-ui-npm@production/schemas/components.json",
189202
+ srcDir: projectInfo.isSrcDir,
189123
189203
  tailwind: {
189124
189204
  config: projectInfo.tailwindConfig || "tailwind.config.ts",
189125
189205
  css: projectInfo.tailwindCss || (projectInfo.isSrcDir ? "src/index.css" : "index.css"),
@@ -189340,7 +189420,7 @@ function pascalCase(str) {
189340
189420
  var import_picocolors2 = __toESM(require_picocolors(), 1);
189341
189421
  var program2 = new Command;
189342
189422
  program2.name("happlyui").description("Add HapplyUI components to your project").version("0.0.1");
189343
- program2.command("init").description("Initialize your project with HapplyUI").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-y, --yes", "Skip prompts and use defaults").option("--defaults", "Use default configuration").action(init);
189423
+ program2.command("init").description("Initialize your project with HapplyUI").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-y, --yes", "Skip prompts and use defaults").option("--defaults", "Use default configuration").option("--base-color <color>", "Base color theme (slate, gray, zinc, neutral, stone)").option("--no-css-variables", "Disable CSS variables for colors").action(init);
189344
189424
  program2.command("add").description("Add components to your project").argument("[components...]", "Components to add").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-y, --yes", "Skip prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Add all available components").option("-p, --path <path>", "Custom path for components").action(add);
189345
189425
  program2.command("list").description("List all available components").option("-c, --cwd <path>", "Working directory", process.cwd()).action(async (options) => {
189346
189426
  const { getAvailableComponents: getAvailableComponents2 } = await Promise.resolve().then(() => (init_registry(), exports_registry));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happlyui/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Add HapplyUI components to your project",
5
5
  "type": "module",
6
6
  "bin": {