create-prisma-php-app 4.0.0-alpha.41 → 4.0.0-alpha.45
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.js +69 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1813,10 +1813,58 @@ async function main() {
|
|
|
1813
1813
|
let existingConfig = null;
|
|
1814
1814
|
const finalProjectConfigPath = path.join(projectPath, "prisma-php.json");
|
|
1815
1815
|
// Function to find prisma-php.json files with excludeFiles
|
|
1816
|
-
const findConfigWithExclusions = (searchDir) => {
|
|
1816
|
+
const findConfigWithExclusions = (searchDir, preferredProjectName) => {
|
|
1817
1817
|
const entries = fs.readdirSync(searchDir, { withFileTypes: true });
|
|
1818
|
+
// First, try to find the preferred project directory
|
|
1819
|
+
if (preferredProjectName) {
|
|
1820
|
+
const preferredEntry = entries.find(
|
|
1821
|
+
(entry) =>
|
|
1822
|
+
entry.isDirectory() &&
|
|
1823
|
+
entry.name.toLowerCase() === preferredProjectName.toLowerCase()
|
|
1824
|
+
);
|
|
1825
|
+
if (preferredEntry) {
|
|
1826
|
+
const preferredConfigPath = path.join(
|
|
1827
|
+
searchDir,
|
|
1828
|
+
preferredEntry.name,
|
|
1829
|
+
"prisma-php.json"
|
|
1830
|
+
);
|
|
1831
|
+
if (fs.existsSync(preferredConfigPath)) {
|
|
1832
|
+
try {
|
|
1833
|
+
const config = JSON.parse(
|
|
1834
|
+
fs.readFileSync(preferredConfigPath, "utf8")
|
|
1835
|
+
);
|
|
1836
|
+
if (config.excludeFiles && config.excludeFiles.length > 0) {
|
|
1837
|
+
console.log(
|
|
1838
|
+
chalk.blue(
|
|
1839
|
+
`Found preferred configuration with exclusions in: ${preferredEntry.name}/`
|
|
1840
|
+
)
|
|
1841
|
+
);
|
|
1842
|
+
console.log(
|
|
1843
|
+
chalk.gray(
|
|
1844
|
+
`Preferred excludeFiles: ${JSON.stringify(
|
|
1845
|
+
config.excludeFiles
|
|
1846
|
+
)}`
|
|
1847
|
+
)
|
|
1848
|
+
);
|
|
1849
|
+
return config;
|
|
1850
|
+
}
|
|
1851
|
+
} catch (error) {
|
|
1852
|
+
console.warn(
|
|
1853
|
+
chalk.yellow(
|
|
1854
|
+
`Could not read preferred config in ${preferredEntry.name}/`
|
|
1855
|
+
)
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
// If no preferred project found, search all directories
|
|
1818
1862
|
for (const entry of entries) {
|
|
1819
|
-
if (
|
|
1863
|
+
if (
|
|
1864
|
+
entry.isDirectory() &&
|
|
1865
|
+
(!preferredProjectName ||
|
|
1866
|
+
entry.name.toLowerCase() !== preferredProjectName.toLowerCase())
|
|
1867
|
+
) {
|
|
1820
1868
|
const subConfigPath = path.join(
|
|
1821
1869
|
searchDir,
|
|
1822
1870
|
entry.name,
|
|
@@ -1828,12 +1876,14 @@ async function main() {
|
|
|
1828
1876
|
if (config.excludeFiles && config.excludeFiles.length > 0) {
|
|
1829
1877
|
console.log(
|
|
1830
1878
|
chalk.blue(
|
|
1831
|
-
`Found configuration with exclusions in: ${entry.name}/`
|
|
1879
|
+
`Found fallback configuration with exclusions in: ${entry.name}/`
|
|
1832
1880
|
)
|
|
1833
1881
|
);
|
|
1834
1882
|
console.log(
|
|
1835
1883
|
chalk.gray(
|
|
1836
|
-
`
|
|
1884
|
+
`Fallback excludeFiles: ${JSON.stringify(
|
|
1885
|
+
config.excludeFiles
|
|
1886
|
+
)}`
|
|
1837
1887
|
)
|
|
1838
1888
|
);
|
|
1839
1889
|
return config;
|
|
@@ -1848,35 +1898,27 @@ async function main() {
|
|
|
1848
1898
|
}
|
|
1849
1899
|
return null;
|
|
1850
1900
|
};
|
|
1851
|
-
//
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
);
|
|
1901
|
+
// If no config in current directory, search subdirectories for configs with excludeFiles
|
|
1902
|
+
if (!existingConfig) {
|
|
1903
|
+
console.log(
|
|
1904
|
+
chalk.blue("Searching for existing configurations with exclusions...")
|
|
1905
|
+
);
|
|
1906
|
+
// Extract project name from starter kit source URL to prioritize the right project
|
|
1907
|
+
let preferredProjectName;
|
|
1908
|
+
if (answer.starterKitSource) {
|
|
1909
|
+
const urlParts = answer.starterKitSource.split("/");
|
|
1910
|
+
const repoName = urlParts[urlParts.length - 1].replace(".git", "");
|
|
1911
|
+
preferredProjectName = repoName;
|
|
1863
1912
|
console.log(
|
|
1864
1913
|
chalk.gray(
|
|
1865
|
-
`
|
|
1866
|
-
existingConfig.excludeFiles || []
|
|
1867
|
-
)}`
|
|
1914
|
+
`Looking for local project matching: ${preferredProjectName}`
|
|
1868
1915
|
)
|
|
1869
1916
|
);
|
|
1870
|
-
} catch (error) {
|
|
1871
|
-
console.warn(chalk.yellow("Could not read current directory config"));
|
|
1872
1917
|
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
console.log(
|
|
1877
|
-
chalk.blue("Searching for existing configurations with exclusions...")
|
|
1918
|
+
existingConfig = findConfigWithExclusions(
|
|
1919
|
+
currentDir,
|
|
1920
|
+
preferredProjectName
|
|
1878
1921
|
);
|
|
1879
|
-
existingConfig = findConfigWithExclusions(currentDir);
|
|
1880
1922
|
}
|
|
1881
1923
|
// If still no config, check the target project directory
|
|
1882
1924
|
if (!existingConfig && fs.existsSync(finalProjectConfigPath)) {
|