create-krispya 0.5.2 → 0.5.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 (3) hide show
  1. package/dist/cli.cjs +21 -29
  2. package/dist/cli.mjs +21 -29
  3. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -821,29 +821,26 @@ async function getMonorepoScope(monorepoRoot) {
821
821
  }
822
822
  async function getWorkspacePackages(monorepoRoot) {
823
823
  const packagesDir = path.join(monorepoRoot, "packages");
824
- const packages = [];
825
824
  try {
826
825
  const { readdir } = await import('fs/promises');
827
826
  const entries = await readdir(packagesDir, { withFileTypes: true });
827
+ const names = [];
828
828
  for (const entry of entries) {
829
- if (entry.isDirectory()) {
830
- try {
831
- const pkgJsonPath = path.join(packagesDir, entry.name, "package.json");
832
- const content = await promises.readFile(pkgJsonPath, "utf-8");
833
- const pkgJson = JSON.parse(content);
834
- if (pkgJson.name) {
835
- packages.push({
836
- name: pkgJson.name,
837
- path: `packages/${entry.name}`
838
- });
839
- }
840
- } catch {
841
- }
829
+ if (!entry.isDirectory()) continue;
830
+ try {
831
+ const content = await promises.readFile(
832
+ path.join(packagesDir, entry.name, "package.json"),
833
+ "utf-8"
834
+ );
835
+ const pkg2 = JSON.parse(content);
836
+ if (pkg2.name) names.push(pkg2.name);
837
+ } catch {
842
838
  }
843
839
  }
840
+ return names;
844
841
  } catch {
842
+ return [];
845
843
  }
846
- return packages;
847
844
  }
848
845
  async function ensureConfigInWorkspace(monorepoRoot) {
849
846
  const workspacePath = path.join(monorepoRoot, "pnpm-workspace.yaml");
@@ -1147,20 +1144,15 @@ async function createPackageInWorkspace(monorepoRoot, packageManager, inheritedT
1147
1144
  }
1148
1145
  await Promise.all(versionPromises);
1149
1146
  packageOptions.versions = versions;
1150
- if (packageType === "app") {
1151
- const workspacePackages = await getWorkspacePackages(monorepoRoot);
1152
- if (workspacePackages.length > 0) {
1153
- const selectedDeps = await p__namespace.multiselect({
1154
- message: "Add workspace dependencies?",
1155
- options: workspacePackages.map((pkgInfo) => ({
1156
- value: pkgInfo.name,
1157
- label: pkgInfo.name.replace(/^@[^/]+\//, "")
1158
- })),
1159
- required: false
1160
- });
1161
- if (!p__namespace.isCancel(selectedDeps) && selectedDeps.length > 0) {
1162
- packageOptions.workspaceDependencies = selectedDeps;
1163
- }
1147
+ const workspacePackages = packageType === "app" ? await getWorkspacePackages(monorepoRoot) : [];
1148
+ if (workspacePackages.length > 0) {
1149
+ const selectedDeps = await p__namespace.multiselect({
1150
+ message: "Add workspace dependencies?",
1151
+ options: workspacePackages.map((name) => ({ value: name, label: name })),
1152
+ required: false
1153
+ });
1154
+ if (!p__namespace.isCancel(selectedDeps) && selectedDeps.length > 0) {
1155
+ packageOptions.workspaceDependencies = selectedDeps;
1164
1156
  }
1165
1157
  }
1166
1158
  const outputPath = path.join(monorepoRoot, relativePkgPath);
package/dist/cli.mjs CHANGED
@@ -800,29 +800,26 @@ async function getMonorepoScope(monorepoRoot) {
800
800
  }
801
801
  async function getWorkspacePackages(monorepoRoot) {
802
802
  const packagesDir = join(monorepoRoot, "packages");
803
- const packages = [];
804
803
  try {
805
804
  const { readdir } = await import('fs/promises');
806
805
  const entries = await readdir(packagesDir, { withFileTypes: true });
806
+ const names = [];
807
807
  for (const entry of entries) {
808
- if (entry.isDirectory()) {
809
- try {
810
- const pkgJsonPath = join(packagesDir, entry.name, "package.json");
811
- const content = await readFile(pkgJsonPath, "utf-8");
812
- const pkgJson = JSON.parse(content);
813
- if (pkgJson.name) {
814
- packages.push({
815
- name: pkgJson.name,
816
- path: `packages/${entry.name}`
817
- });
818
- }
819
- } catch {
820
- }
808
+ if (!entry.isDirectory()) continue;
809
+ try {
810
+ const content = await readFile(
811
+ join(packagesDir, entry.name, "package.json"),
812
+ "utf-8"
813
+ );
814
+ const pkg2 = JSON.parse(content);
815
+ if (pkg2.name) names.push(pkg2.name);
816
+ } catch {
821
817
  }
822
818
  }
819
+ return names;
823
820
  } catch {
821
+ return [];
824
822
  }
825
- return packages;
826
823
  }
827
824
  async function ensureConfigInWorkspace(monorepoRoot) {
828
825
  const workspacePath = join(monorepoRoot, "pnpm-workspace.yaml");
@@ -1126,20 +1123,15 @@ async function createPackageInWorkspace(monorepoRoot, packageManager, inheritedT
1126
1123
  }
1127
1124
  await Promise.all(versionPromises);
1128
1125
  packageOptions.versions = versions;
1129
- if (packageType === "app") {
1130
- const workspacePackages = await getWorkspacePackages(monorepoRoot);
1131
- if (workspacePackages.length > 0) {
1132
- const selectedDeps = await p.multiselect({
1133
- message: "Add workspace dependencies?",
1134
- options: workspacePackages.map((pkgInfo) => ({
1135
- value: pkgInfo.name,
1136
- label: pkgInfo.name.replace(/^@[^/]+\//, "")
1137
- })),
1138
- required: false
1139
- });
1140
- if (!p.isCancel(selectedDeps) && selectedDeps.length > 0) {
1141
- packageOptions.workspaceDependencies = selectedDeps;
1142
- }
1126
+ const workspacePackages = packageType === "app" ? await getWorkspacePackages(monorepoRoot) : [];
1127
+ if (workspacePackages.length > 0) {
1128
+ const selectedDeps = await p.multiselect({
1129
+ message: "Add workspace dependencies?",
1130
+ options: workspacePackages.map((name) => ({ value: name, label: name })),
1131
+ required: false
1132
+ });
1133
+ if (!p.isCancel(selectedDeps) && selectedDeps.length > 0) {
1134
+ packageOptions.workspaceDependencies = selectedDeps;
1143
1135
  }
1144
1136
  }
1145
1137
  const outputPath = join(monorepoRoot, relativePkgPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-krispya",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "🌹 CLI for creating web projects with (my) sensible defaults",
5
5
  "keywords": [
6
6
  "cli",