codeplay-common 1.2.4 → 1.2.6

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.
@@ -1,7 +1,7 @@
1
- {
2
- "name": "merbin-test-app",
3
- "integrations": {
4
- "capacitor": {}
5
- },
6
- "type": "custom"
1
+ {
2
+ "name": "merbin-test-app",
3
+ "integrations": {
4
+ "capacitor": {}
5
+ },
6
+ "type": "custom"
7
7
  }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
- {
2
- "name": "codeplay-common",
3
- "version": "1.2.4",
4
- "description": "Common build scripts and files",
5
- "scripts": {
6
- "postinstall": "node scripts/sync-files.js",
7
- "preinstall": "node scripts/uninstall.js"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/merbin2012/codeplay-common.git"
12
- },
13
- "author": "Codeplay Technologies",
14
- "license": "MIT"
1
+ {
2
+ "name": "codeplay-common",
3
+ "version": "1.2.6",
4
+ "description": "Common build scripts and files",
5
+ "scripts": {
6
+ "postinstall": "node scripts/sync-files.js",
7
+ "preinstall": "node scripts/uninstall.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/merbin2012/codeplay-common.git"
12
+ },
13
+ "author": "Codeplay Technologies",
14
+ "license": "MIT"
15
15
  }
@@ -1,78 +1,78 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
5
- const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
6
- const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
7
- const packageJsonPath = path.join(projectRoot, "package.json");
8
-
9
- // Ensure package.json exists
10
- if (!fs.existsSync(packageJsonPath)) {
11
- process.stderr.write("❌ package.json not found!\n");
12
- process.exit(1);
13
- }
14
-
15
- function copyFolderSync(source, destination) {
16
- try {
17
- fs.cpSync(source, destination, { recursive: true });
18
- process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
19
- } catch (error) {
20
- process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
21
- }
22
- }
23
-
24
- // Copy all files from `common-build-files/files/` to the project root
25
- fs.readdirSync(commonBuildPath).forEach(file => {
26
- const sourcePath = path.join(commonBuildPath, file);
27
- const destPath = path.join(projectRoot, file);
28
-
29
- if (fs.statSync(sourcePath).isDirectory()) {
30
- copyFolderSync(sourcePath, destPath);
31
- } else {
32
- try {
33
- fs.copyFileSync(sourcePath, destPath);
34
- process.stdout.write(`✅ Copied file: ${file}\n`);
35
- } catch (error) {
36
- process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
37
- }
38
- }
39
- });
40
-
41
- // Function to get the latest versioned file from files/buildCodeplay
42
- function getLatestFile(prefix) {
43
- if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
44
-
45
- const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
46
- if (files.length === 0) return null;
47
- files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
48
- return files[0];
49
- }
50
-
51
- // Detect latest script versions
52
- const latestSplashScreen = getLatestFile("add-splash-screen-");
53
- const latestSplashAnimation = getLatestFile("setSplashAnimation-");
54
- const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
55
-
56
- // Update package.json
57
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
58
-
59
- // Ensure scripts object exists
60
- packageJson.scripts = packageJson.scripts || {};
61
-
62
- // Update or add necessary scripts
63
- if (latestCodeplayBuild) {
64
- packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && cross-env NODE_ENV=production vite build`;
65
- }
66
- if (latestSplashScreen && latestSplashAnimation) {
67
- packageJson.scripts["capacitor:sync:after"] = `node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
68
- }
69
-
70
- packageJson.scripts["ionic:build"] = "npm run build";
71
- packageJson.scripts["ionic:serve"] = "npm run start";
72
- packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
73
- packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
74
- packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
75
-
76
- // Save changes
77
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
78
- process.stdout.write("✅ package.json updated!\n");
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
5
+ const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
6
+ const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
7
+ const packageJsonPath = path.join(projectRoot, "package.json");
8
+
9
+ // Ensure package.json exists
10
+ if (!fs.existsSync(packageJsonPath)) {
11
+ process.stderr.write("❌ package.json not found!\n");
12
+ process.exit(1);
13
+ }
14
+
15
+ function copyFolderSync(source, destination) {
16
+ try {
17
+ fs.cpSync(source, destination, { recursive: true });
18
+ process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
19
+ } catch (error) {
20
+ process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
21
+ }
22
+ }
23
+
24
+ // Copy all files from `common-build-files/files/` to the project root
25
+ fs.readdirSync(commonBuildPath).forEach(file => {
26
+ const sourcePath = path.join(commonBuildPath, file);
27
+ const destPath = path.join(projectRoot, file);
28
+
29
+ if (fs.statSync(sourcePath).isDirectory()) {
30
+ copyFolderSync(sourcePath, destPath);
31
+ } else {
32
+ try {
33
+ fs.copyFileSync(sourcePath, destPath);
34
+ process.stdout.write(`✅ Copied file: ${file}\n`);
35
+ } catch (error) {
36
+ process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
37
+ }
38
+ }
39
+ });
40
+
41
+ // Function to get the latest versioned file from files/buildCodeplay
42
+ function getLatestFile(prefix) {
43
+ if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
44
+
45
+ const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
46
+ if (files.length === 0) return null;
47
+ files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
48
+ return files[0];
49
+ }
50
+
51
+ // Detect latest script versions
52
+ const latestSplashScreen = getLatestFile("add-splash-screen-");
53
+ const latestSplashAnimation = getLatestFile("setSplashAnimation-");
54
+ const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
55
+
56
+ // Update package.json
57
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
58
+
59
+ // Ensure scripts object exists
60
+ packageJson.scripts = packageJson.scripts || {};
61
+
62
+ // Update or add necessary scripts
63
+ if (latestCodeplayBuild) {
64
+ packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && cross-env NODE_ENV=production vite build`;
65
+ }
66
+ if (latestSplashScreen && latestSplashAnimation) {
67
+ packageJson.scripts["capacitor:sync:after"] = `node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
68
+ }
69
+
70
+ packageJson.scripts["ionic:build"] = "npm run build";
71
+ packageJson.scripts["ionic:serve"] = "npm run start";
72
+ packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
73
+ packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
74
+ packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
75
+
76
+ // Save changes
77
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
78
+ process.stdout.write("✅ package.json updated!\n");
@@ -1,76 +1,76 @@
1
- // Define file prefixes to delete
2
- const filePrefixes = [
3
- "add-splash-screen",
4
- "setSplashAnimation",
5
- "codeplayBeforeBuild",
6
- "finalrelease"
7
- ];
8
-
9
- const fs = require("fs");
10
- const path = require("path");
11
-
12
- const projectRoot = path.resolve(__dirname, "../../../"); // Project root
13
- const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
14
- const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
15
-
16
- process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
17
-
18
- const removeDirectory = (dirPath) => {
19
- if (fs.existsSync(dirPath)) {
20
- fs.readdirSync(dirPath).forEach(file => {
21
- const currentPath = path.join(dirPath, file);
22
- if (fs.lstatSync(currentPath).isDirectory()) {
23
- removeDirectory(currentPath);
24
- } else {
25
- fs.unlinkSync(currentPath);
26
- }
27
- });
28
- fs.rmdirSync(dirPath);
29
- process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
30
- }
31
- };
32
-
33
- removeDirectory(splashXmlPath);
34
- removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
35
-
36
- // Step 1: Find all matching files in the project directory
37
- const filePatternsToRemove = [
38
- /^add-splash-screen-.*$/,
39
- /^setSplashAnimation-.*$/,
40
- /^codeplayBeforeBuild-.*$/,
41
- /^modify-plugin-xml\.xml$/,
42
- /^finalrelease.*$/,
43
- /^\.env\.storeid[1-7]$/,
44
- /^modify-plugin-xml\.js$/
45
- ];
46
-
47
- const filesInProject = fs.readdirSync(projectRoot);
48
-
49
- filesInProject.forEach(file => {
50
- if (filePatternsToRemove.some(pattern => pattern.test(file))) {
51
- const filePath = path.join(projectRoot, file);
52
- try {
53
- fs.unlinkSync(filePath);
54
- process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
55
- } catch (error) {
56
- process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
57
- }
58
- }
59
- });
60
-
61
- // Remove files listed in commonBuildPath
62
- if (fs.existsSync(commonBuildPath)) {
63
- fs.readdirSync(commonBuildPath).forEach(file => {
64
- const destPath = path.join(projectRoot, file);
65
- if (fs.existsSync(destPath)) {
66
- try {
67
- fs.unlinkSync(destPath);
68
- process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
69
- } catch (error) {
70
- process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
71
- }
72
- }
73
- });
74
- }
75
-
76
- process.stdout.write("✅ Uninstall cleanup complete!\n");
1
+ // Define file prefixes to delete
2
+ const filePrefixes = [
3
+ "add-splash-screen",
4
+ "setSplashAnimation",
5
+ "codeplayBeforeBuild",
6
+ "finalrelease"
7
+ ];
8
+
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+
12
+ const projectRoot = path.resolve(__dirname, "../../../"); // Project root
13
+ const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
14
+ const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
15
+
16
+ process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
17
+
18
+ const removeDirectory = (dirPath) => {
19
+ if (fs.existsSync(dirPath)) {
20
+ fs.readdirSync(dirPath).forEach(file => {
21
+ const currentPath = path.join(dirPath, file);
22
+ if (fs.lstatSync(currentPath).isDirectory()) {
23
+ removeDirectory(currentPath);
24
+ } else {
25
+ fs.unlinkSync(currentPath);
26
+ }
27
+ });
28
+ fs.rmdirSync(dirPath);
29
+ process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
30
+ }
31
+ };
32
+
33
+ removeDirectory(splashXmlPath);
34
+ removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
35
+
36
+ // Step 1: Find all matching files in the project directory
37
+ const filePatternsToRemove = [
38
+ /^add-splash-screen-.*$/,
39
+ /^setSplashAnimation-.*$/,
40
+ /^codeplayBeforeBuild-.*$/,
41
+ /^modify-plugin-xml\.xml$/,
42
+ /^finalrelease.*$/,
43
+ /^\.env\.storeid[1-7]$/,
44
+ /^modify-plugin-xml\.js$/
45
+ ];
46
+
47
+ const filesInProject = fs.readdirSync(projectRoot);
48
+
49
+ filesInProject.forEach(file => {
50
+ if (filePatternsToRemove.some(pattern => pattern.test(file))) {
51
+ const filePath = path.join(projectRoot, file);
52
+ try {
53
+ fs.unlinkSync(filePath);
54
+ process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
55
+ } catch (error) {
56
+ process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
57
+ }
58
+ }
59
+ });
60
+
61
+ // Remove files listed in commonBuildPath
62
+ if (fs.existsSync(commonBuildPath)) {
63
+ fs.readdirSync(commonBuildPath).forEach(file => {
64
+ const destPath = path.join(projectRoot, file);
65
+ if (fs.existsSync(destPath)) {
66
+ try {
67
+ fs.unlinkSync(destPath);
68
+ process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
69
+ } catch (error) {
70
+ process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
71
+ }
72
+ }
73
+ });
74
+ }
75
+
76
+ process.stdout.write("✅ Uninstall cleanup complete!\n");