codeplay-common 1.0.2 → 1.0.4
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/package.json +2 -2
- package/scripts/sync-files.js +13 -43
package/package.json
CHANGED
package/scripts/sync-files.js
CHANGED
|
@@ -3,56 +3,26 @@ const path = require("path");
|
|
|
3
3
|
|
|
4
4
|
const projectRoot = process.cwd(); // Your project's root
|
|
5
5
|
const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
|
|
6
|
-
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
7
6
|
|
|
8
|
-
// Function to
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
// Function to safely copy a file
|
|
8
|
+
function safeCopyFile(source, dest) {
|
|
9
|
+
try {
|
|
10
|
+
fs.copyFileSync(source, dest);
|
|
11
|
+
console.log(`✅ Copied: ${path.basename(source)}`);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn(`⚠️ Failed to copy: ${path.basename(source)} - ${error.message}`);
|
|
14
|
+
}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
// Ensure
|
|
17
|
-
if (
|
|
18
|
-
console.error("❌
|
|
17
|
+
// Ensure we are not copying inside node_modules
|
|
18
|
+
if (__dirname.includes("node_modules")) {
|
|
19
|
+
console.error("❌ Error: Do not copy files inside node_modules!");
|
|
19
20
|
process.exit(1);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
// Copy all files
|
|
23
|
+
// Copy all files to project root
|
|
23
24
|
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
24
25
|
const sourcePath = path.join(commonBuildPath, file);
|
|
25
26
|
const destPath = path.join(projectRoot, file);
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
29
|
-
console.log(`✅ Copied: ${file}`);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.warn(`⚠️ Failed to copy: ${file} - ${error.message}`);
|
|
32
|
-
}
|
|
27
|
+
safeCopyFile(sourcePath, destPath);
|
|
33
28
|
});
|
|
34
|
-
|
|
35
|
-
// Detect latest script versions
|
|
36
|
-
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
37
|
-
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
38
|
-
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
39
|
-
|
|
40
|
-
// Update package.json
|
|
41
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
42
|
-
|
|
43
|
-
if (latestSplashScreen) {
|
|
44
|
-
packageJson.scripts["capacitor:sync:after"] = packageJson.scripts["capacitor:sync:after"]
|
|
45
|
-
.replace(/add-splash-screen-\d+\.\d+\.js/, latestSplashScreen);
|
|
46
|
-
}
|
|
47
|
-
if (latestSplashAnimation) {
|
|
48
|
-
packageJson.scripts["capacitor:sync:after"] = packageJson.scripts["capacitor:sync:after"]
|
|
49
|
-
.replace(/setSplashAnimation-\d+\.\d+\.js/, latestSplashAnimation);
|
|
50
|
-
}
|
|
51
|
-
if (latestCodeplayBuild) {
|
|
52
|
-
packageJson.scripts["build"] = packageJson.scripts["build"]
|
|
53
|
-
.replace(/codeplayBeforeBuild-\d+\.\d+\.js/, latestCodeplayBuild);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Save changes
|
|
57
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
58
|
-
console.log("✅ package.json updated!");
|