create-boltdocs 0.3.0 → 0.3.2

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.cjs CHANGED
@@ -60,62 +60,82 @@ async function run() {
60
60
  | |_) | |_| | |___ | | | |_| | |_| | |___ ___) |
61
61
  |____/ \\___/|_____| |_| |____/ \\___/ \\____|____/`)));
62
62
  console.log(_bdocs_dui.colors.dim(`\n v0.0.4 - The modern documentation framework\n`));
63
+ let argProjectName = "";
64
+ let argTemplate = "";
65
+ let argInstall = void 0;
66
+ const args = process.argv.slice(2);
67
+ for (let i = 0; i < args.length; i++) {
68
+ const arg = args[i];
69
+ if (arg === "--template" || arg === "-t") argTemplate = args[++i];
70
+ else if (arg === "--install" || arg === "-i") argInstall = true;
71
+ else if (arg === "--no-install") argInstall = false;
72
+ else if (!arg.startsWith("-")) {
73
+ if (!argProjectName) argProjectName = arg;
74
+ }
75
+ }
76
+ if (argTemplate && argTemplate !== "base" && argTemplate !== "i18n") {
77
+ (0, _bdocs_dui.warn)(`Template "${argTemplate}" is invalid. Falling back to prompt.`);
78
+ argTemplate = "";
79
+ }
63
80
  const response = await (0, prompts.default)([
64
- {
81
+ ...argProjectName ? [] : [{
65
82
  type: "text",
66
83
  name: "projectName",
67
84
  message: "Project name:",
68
85
  initial: "my-boltdocs-app"
69
- },
70
- {
86
+ }],
87
+ ...argTemplate ? [] : [{
71
88
  type: "select",
72
89
  name: "template",
73
90
  message: "Select a project preset:",
74
91
  choices: [{
75
- title: magenta("Base"),
92
+ title: _bdocs_dui.colors.magenta("Base"),
76
93
  description: "Hero and custom components.",
77
94
  value: "base"
78
95
  }, {
79
- title: yellow("i18n"),
96
+ title: _bdocs_dui.colors.yellow("i18n"),
80
97
  description: "Multi-language support (EN/ES).",
81
98
  value: "i18n"
82
99
  }],
83
100
  initial: 0
84
- },
85
- {
101
+ }],
102
+ ...argInstall !== void 0 ? [] : [{
86
103
  type: "confirm",
87
104
  name: "install",
88
105
  message: `Install dependencies with ${_bdocs_dui.colors.bold(pkgManager)}?`,
89
106
  initial: true
90
- }
107
+ }]
91
108
  ]);
92
- if (!response.projectName || !response.template) {
109
+ const projectName = argProjectName || response.projectName;
110
+ const template = argTemplate || response.template;
111
+ const install = argInstall !== void 0 ? argInstall : response.install;
112
+ if (!projectName || !template) {
93
113
  (0, _bdocs_dui.warn)("Operation canceled.");
94
114
  return;
95
115
  }
96
- const projectDir = node_path.default.join(process.cwd(), response.projectName);
116
+ const projectDir = node_path.default.join(process.cwd(), projectName);
97
117
  if (node_fs.default.existsSync(projectDir)) {
98
- (0, _bdocs_dui.error)(`Directory "${response.projectName}" already exists.`);
118
+ (0, _bdocs_dui.error)(`Directory "${projectName}" already exists.`);
99
119
  process.exit(1);
100
120
  }
101
121
  (0, _bdocs_dui.info)("Building your documentation site...");
102
122
  const __dirname = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
103
- const templateDir = node_path.default.resolve(__dirname, "templates", response.template);
123
+ const templateDir = node_path.default.resolve(__dirname, "templates", template);
104
124
  if (!node_fs.default.existsSync(templateDir)) {
105
- (0, _bdocs_dui.error)(`Template "${response.template}" not found at ${templateDir}`);
125
+ (0, _bdocs_dui.error)(`Template "${template}" not found at ${templateDir}`);
106
126
  process.exit(1);
107
127
  }
108
128
  try {
109
129
  copy(templateDir, projectDir, {
110
- name: response.projectName,
111
- title: response.projectName
130
+ name: projectName,
131
+ title: projectName
112
132
  });
113
- (0, _bdocs_dui.success)(`Created project structure and applied "${response.template}" preset`);
133
+ (0, _bdocs_dui.success)(`Created project structure and applied "${template}" preset`);
114
134
  } catch (e) {
115
135
  (0, _bdocs_dui.error)(`Error copying template: ${e instanceof Error ? e.message : String(e)}`);
116
136
  process.exit(1);
117
137
  }
118
- if (response.install) {
138
+ if (install) {
119
139
  (0, _bdocs_dui.info)(`Installing dependencies with ${pkgManager}...`);
120
140
  try {
121
141
  (0, node_child_process.execSync)(`${pkgManager} install`, {
@@ -129,8 +149,8 @@ async function run() {
129
149
  }
130
150
  (0, _bdocs_dui.success)("✨ All set! Your documentation is ready. ✨");
131
151
  console.log(`To start developing:`);
132
- console.log(` cd ${response.projectName}`);
133
- if (!response.install) console.log(` ${pkgManager} install`);
152
+ console.log(` cd ${projectName}`);
153
+ if (!install) console.log(` ${pkgManager} install`);
134
154
  console.log(` ${pkgManager} run dev\n`);
135
155
  }
136
156
  run().catch((e) => (0, _bdocs_dui.error)("Unhandled error", e));
package/dist/index.mjs CHANGED
@@ -35,62 +35,82 @@ async function run() {
35
35
  | |_) | |_| | |___ | | | |_| | |_| | |___ ___) |
36
36
  |____/ \\___/|_____| |_| |____/ \\___/ \\____|____/`)));
37
37
  console.log(colors.dim(`\n v0.0.4 - The modern documentation framework\n`));
38
+ let argProjectName = "";
39
+ let argTemplate = "";
40
+ let argInstall = void 0;
41
+ const args = process.argv.slice(2);
42
+ for (let i = 0; i < args.length; i++) {
43
+ const arg = args[i];
44
+ if (arg === "--template" || arg === "-t") argTemplate = args[++i];
45
+ else if (arg === "--install" || arg === "-i") argInstall = true;
46
+ else if (arg === "--no-install") argInstall = false;
47
+ else if (!arg.startsWith("-")) {
48
+ if (!argProjectName) argProjectName = arg;
49
+ }
50
+ }
51
+ if (argTemplate && argTemplate !== "base" && argTemplate !== "i18n") {
52
+ warn(`Template "${argTemplate}" is invalid. Falling back to prompt.`);
53
+ argTemplate = "";
54
+ }
38
55
  const response = await prompts([
39
- {
56
+ ...argProjectName ? [] : [{
40
57
  type: "text",
41
58
  name: "projectName",
42
59
  message: "Project name:",
43
60
  initial: "my-boltdocs-app"
44
- },
45
- {
61
+ }],
62
+ ...argTemplate ? [] : [{
46
63
  type: "select",
47
64
  name: "template",
48
65
  message: "Select a project preset:",
49
66
  choices: [{
50
- title: magenta("Base"),
67
+ title: colors.magenta("Base"),
51
68
  description: "Hero and custom components.",
52
69
  value: "base"
53
70
  }, {
54
- title: yellow("i18n"),
71
+ title: colors.yellow("i18n"),
55
72
  description: "Multi-language support (EN/ES).",
56
73
  value: "i18n"
57
74
  }],
58
75
  initial: 0
59
- },
60
- {
76
+ }],
77
+ ...argInstall !== void 0 ? [] : [{
61
78
  type: "confirm",
62
79
  name: "install",
63
80
  message: `Install dependencies with ${colors.bold(pkgManager)}?`,
64
81
  initial: true
65
- }
82
+ }]
66
83
  ]);
67
- if (!response.projectName || !response.template) {
84
+ const projectName = argProjectName || response.projectName;
85
+ const template = argTemplate || response.template;
86
+ const install = argInstall !== void 0 ? argInstall : response.install;
87
+ if (!projectName || !template) {
68
88
  warn("Operation canceled.");
69
89
  return;
70
90
  }
71
- const projectDir = path.join(process.cwd(), response.projectName);
91
+ const projectDir = path.join(process.cwd(), projectName);
72
92
  if (fs.existsSync(projectDir)) {
73
- error(`Directory "${response.projectName}" already exists.`);
93
+ error(`Directory "${projectName}" already exists.`);
74
94
  process.exit(1);
75
95
  }
76
96
  info("Building your documentation site...");
77
97
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
78
- const templateDir = path.resolve(__dirname, "templates", response.template);
98
+ const templateDir = path.resolve(__dirname, "templates", template);
79
99
  if (!fs.existsSync(templateDir)) {
80
- error(`Template "${response.template}" not found at ${templateDir}`);
100
+ error(`Template "${template}" not found at ${templateDir}`);
81
101
  process.exit(1);
82
102
  }
83
103
  try {
84
104
  copy(templateDir, projectDir, {
85
- name: response.projectName,
86
- title: response.projectName
105
+ name: projectName,
106
+ title: projectName
87
107
  });
88
- success(`Created project structure and applied "${response.template}" preset`);
108
+ success(`Created project structure and applied "${template}" preset`);
89
109
  } catch (e) {
90
110
  error(`Error copying template: ${e instanceof Error ? e.message : String(e)}`);
91
111
  process.exit(1);
92
112
  }
93
- if (response.install) {
113
+ if (install) {
94
114
  info(`Installing dependencies with ${pkgManager}...`);
95
115
  try {
96
116
  execSync(`${pkgManager} install`, {
@@ -104,8 +124,8 @@ async function run() {
104
124
  }
105
125
  success("✨ All set! Your documentation is ready. ✨");
106
126
  console.log(`To start developing:`);
107
- console.log(` cd ${response.projectName}`);
108
- if (!response.install) console.log(` ${pkgManager} install`);
127
+ console.log(` cd ${projectName}`);
128
+ if (!install) console.log(` ${pkgManager} install`);
109
129
  console.log(` ${pkgManager} run dev\n`);
110
130
  }
111
131
  run().catch((e) => error("Unhandled error", e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-boltdocs",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Create a new boltdocs project",
5
5
  "type": "module",
6
6
  "author": "Jesus Alcala",