create-prisma-php-app 4.0.0-alpha.40 → 4.0.0-alpha.41
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 +50 -12
- package/dist/prisma-php.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawnSync } from "child_process";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
@@ -1811,9 +1811,45 @@ async function main() {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
// Check for existing config to merge with
|
|
1813
1813
|
let existingConfig = null;
|
|
1814
|
-
const currentDirConfigPath = path.join(process.cwd(), "prisma-php.json");
|
|
1815
1814
|
const finalProjectConfigPath = path.join(projectPath, "prisma-php.json");
|
|
1816
|
-
//
|
|
1815
|
+
// Function to find prisma-php.json files with excludeFiles
|
|
1816
|
+
const findConfigWithExclusions = (searchDir) => {
|
|
1817
|
+
const entries = fs.readdirSync(searchDir, { withFileTypes: true });
|
|
1818
|
+
for (const entry of entries) {
|
|
1819
|
+
if (entry.isDirectory()) {
|
|
1820
|
+
const subConfigPath = path.join(
|
|
1821
|
+
searchDir,
|
|
1822
|
+
entry.name,
|
|
1823
|
+
"prisma-php.json"
|
|
1824
|
+
);
|
|
1825
|
+
if (fs.existsSync(subConfigPath)) {
|
|
1826
|
+
try {
|
|
1827
|
+
const config = JSON.parse(fs.readFileSync(subConfigPath, "utf8"));
|
|
1828
|
+
if (config.excludeFiles && config.excludeFiles.length > 0) {
|
|
1829
|
+
console.log(
|
|
1830
|
+
chalk.blue(
|
|
1831
|
+
`Found configuration with exclusions in: ${entry.name}/`
|
|
1832
|
+
)
|
|
1833
|
+
);
|
|
1834
|
+
console.log(
|
|
1835
|
+
chalk.gray(
|
|
1836
|
+
`Found excludeFiles: ${JSON.stringify(config.excludeFiles)}`
|
|
1837
|
+
)
|
|
1838
|
+
);
|
|
1839
|
+
return config;
|
|
1840
|
+
}
|
|
1841
|
+
} catch (error) {
|
|
1842
|
+
console.warn(
|
|
1843
|
+
chalk.yellow(`Could not read config in ${entry.name}/`)
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return null;
|
|
1850
|
+
};
|
|
1851
|
+
// First, look in current directory for prisma-php.json
|
|
1852
|
+
const currentDirConfigPath = path.join(currentDir, "prisma-php.json");
|
|
1817
1853
|
if (
|
|
1818
1854
|
fs.existsSync(currentDirConfigPath) &&
|
|
1819
1855
|
currentDirConfigPath !== finalProjectConfigPath
|
|
@@ -1822,31 +1858,33 @@ async function main() {
|
|
|
1822
1858
|
const rawConfig = fs.readFileSync(currentDirConfigPath, "utf8");
|
|
1823
1859
|
existingConfig = JSON.parse(rawConfig);
|
|
1824
1860
|
console.log(
|
|
1825
|
-
chalk.blue(
|
|
1826
|
-
"Found existing configuration in current directory, using exclusions..."
|
|
1827
|
-
)
|
|
1861
|
+
chalk.blue("Found existing configuration in current directory")
|
|
1828
1862
|
);
|
|
1829
1863
|
console.log(
|
|
1830
1864
|
chalk.gray(
|
|
1831
|
-
`
|
|
1865
|
+
`Current dir excludeFiles: ${JSON.stringify(
|
|
1832
1866
|
existingConfig.excludeFiles || []
|
|
1833
1867
|
)}`
|
|
1834
1868
|
)
|
|
1835
1869
|
);
|
|
1836
1870
|
} catch (error) {
|
|
1837
1871
|
console.warn(chalk.yellow("Could not read current directory config"));
|
|
1838
|
-
existingConfig = null;
|
|
1839
1872
|
}
|
|
1840
1873
|
}
|
|
1841
|
-
// If no config in current directory,
|
|
1874
|
+
// If no config in current directory, search subdirectories for configs with excludeFiles
|
|
1875
|
+
if (!existingConfig) {
|
|
1876
|
+
console.log(
|
|
1877
|
+
chalk.blue("Searching for existing configurations with exclusions...")
|
|
1878
|
+
);
|
|
1879
|
+
existingConfig = findConfigWithExclusions(currentDir);
|
|
1880
|
+
}
|
|
1881
|
+
// If still no config, check the target project directory
|
|
1842
1882
|
if (!existingConfig && fs.existsSync(finalProjectConfigPath)) {
|
|
1843
1883
|
try {
|
|
1844
1884
|
const rawConfig = fs.readFileSync(finalProjectConfigPath, "utf8");
|
|
1845
1885
|
existingConfig = JSON.parse(rawConfig);
|
|
1846
1886
|
console.log(
|
|
1847
|
-
chalk.blue(
|
|
1848
|
-
"Found existing configuration in project directory, merging..."
|
|
1849
|
-
)
|
|
1887
|
+
chalk.blue("Found existing configuration in project directory")
|
|
1850
1888
|
);
|
|
1851
1889
|
console.log(
|
|
1852
1890
|
chalk.gray(
|
package/dist/prisma-php.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import chalk from"chalk";import{spawn}from"child_process";import fs from"fs";import path from"path";import prompts from"prompts";const args=process.argv.slice(2),readJsonFile=e=>{const o=fs.readFileSync(e,"utf8");return JSON.parse(o)},executeCommand=(e,o=[],t={})=>new Promise(((r,s)=>{const a=spawn(e,o,{stdio:"inherit",shell:!0,...t});a.on("error",(e=>{s(e)})),a.on("close",(e=>{0===e?r():s(new Error(`Process exited with code ${e}`))}))}));async function getAnswer(){const e=[{type:"toggle",name:"shouldProceed",message:`This command will update the ${chalk.blue("create-prisma-php-app")} package and overwrite all default files. ${chalk.blue("Do you want to proceed")}?`,initial:!1,active:"Yes",inactive:"No"}],o=await prompts(e,{onCancel:()=>{process.exit(0)}});return 0===Object.keys(o).length?null:o}const commandsToExecute={update:"npx pp update project"};
|
|
3
3
|
const main = async () => {
|
|
4
4
|
if (args.length === 0) {
|