create-nextblock 0.2.21 → 0.2.22
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/bin/create-nextblock.js +60 -22
- package/package.json +1 -1
package/bin/create-nextblock.js
CHANGED
|
@@ -723,10 +723,11 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
|
723
723
|
const destSupabaseDir = resolve(projectDir, 'supabase');
|
|
724
724
|
await fs.ensureDir(destSupabaseDir);
|
|
725
725
|
|
|
726
|
-
const packageSupabaseDir = await resolvePackageSupabaseDir();
|
|
726
|
+
const { dir: packageSupabaseDir, triedPaths } = await resolvePackageSupabaseDir(projectDir);
|
|
727
727
|
if (!packageSupabaseDir) {
|
|
728
728
|
const message =
|
|
729
|
-
'Unable to locate supabase assets in @nextblock-cms/db. Please
|
|
729
|
+
'Unable to locate supabase assets in @nextblock-cms/db. Please ensure dependencies are installed.' +
|
|
730
|
+
(triedPaths.length > 0 ? `\nChecked:\n - ${triedPaths.join('\n - ')}` : '');
|
|
730
731
|
if (required) {
|
|
731
732
|
throw new Error(message);
|
|
732
733
|
} else {
|
|
@@ -769,38 +770,75 @@ async function ensureSupabaseAssets(projectDir, options = {}) {
|
|
|
769
770
|
|
|
770
771
|
if (required) {
|
|
771
772
|
if (!configCopied) {
|
|
772
|
-
throw new Error(
|
|
773
|
+
throw new Error(
|
|
774
|
+
`Missing supabase/config.toml in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
|
|
775
|
+
);
|
|
773
776
|
}
|
|
774
777
|
if (!migrationsCopied) {
|
|
775
|
-
throw new Error(
|
|
778
|
+
throw new Error(
|
|
779
|
+
`Missing supabase/migrations in the installed @nextblock-cms/db package (checked ${packageSupabaseDir}).`,
|
|
780
|
+
);
|
|
776
781
|
}
|
|
777
782
|
}
|
|
778
783
|
|
|
779
784
|
return { migrationsCopied, configCopied, projectId: detectedProjectId };
|
|
780
785
|
}
|
|
781
786
|
|
|
782
|
-
async function resolvePackageSupabaseDir() {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
'
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
787
|
+
async function resolvePackageSupabaseDir(projectDir) {
|
|
788
|
+
const triedPaths = [];
|
|
789
|
+
const candidateBases = new Set();
|
|
790
|
+
|
|
791
|
+
const installDir = resolve(projectDir, 'node_modules', '@nextblock-cms', 'db');
|
|
792
|
+
candidateBases.add(installDir);
|
|
793
|
+
|
|
794
|
+
const tryResolveFrom = (fromPath) => {
|
|
795
|
+
try {
|
|
796
|
+
const resolver = createRequire(fromPath);
|
|
797
|
+
const pkgPath = resolver.resolve('@nextblock-cms/db/package.json');
|
|
798
|
+
return dirname(pkgPath);
|
|
799
|
+
} catch {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
const projectPkg = resolve(projectDir, 'package.json');
|
|
805
|
+
const resolvedProject = tryResolveFrom(projectPkg);
|
|
806
|
+
if (resolvedProject) {
|
|
807
|
+
candidateBases.add(resolvedProject);
|
|
808
|
+
const parent = dirname(resolvedProject);
|
|
809
|
+
candidateBases.add(parent);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const localResolve = tryResolveFrom(__filename);
|
|
813
|
+
if (localResolve) {
|
|
814
|
+
candidateBases.add(localResolve);
|
|
815
|
+
candidateBases.add(dirname(localResolve));
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
candidateBases.add(REPO_ROOT);
|
|
819
|
+
candidateBases.add(resolve(REPO_ROOT, 'libs', 'db'));
|
|
820
|
+
candidateBases.add(resolve(REPO_ROOT, 'dist', 'libs', 'db'));
|
|
821
|
+
|
|
822
|
+
const candidateSegments = [
|
|
823
|
+
'supabase',
|
|
824
|
+
'src/supabase',
|
|
825
|
+
'dist/supabase',
|
|
826
|
+
'dist/libs/db/supabase',
|
|
827
|
+
'dist/lib/supabase',
|
|
828
|
+
'lib/supabase',
|
|
829
|
+
];
|
|
830
|
+
|
|
831
|
+
for (const base of Array.from(candidateBases).filter(Boolean)) {
|
|
832
|
+
for (const segment of candidateSegments) {
|
|
833
|
+
const candidate = resolve(base, segment);
|
|
834
|
+
triedPaths.push(candidate);
|
|
796
835
|
if (await fs.pathExists(candidate)) {
|
|
797
|
-
return candidate;
|
|
836
|
+
return { dir: candidate, triedPaths };
|
|
798
837
|
}
|
|
799
838
|
}
|
|
800
|
-
} catch {
|
|
801
|
-
return null;
|
|
802
839
|
}
|
|
803
|
-
|
|
840
|
+
|
|
841
|
+
return { dir: null, triedPaths };
|
|
804
842
|
}
|
|
805
843
|
|
|
806
844
|
async function readSupabaseProjectRef(projectDir) {
|