codeplay-common 4.3.5 → 4.3.7
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/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +125 -125
- package/files/buildCodeplay/codeplayBeforeBuild-6.2.js +4107 -4107
- package/files/buildCodeplay/versions.json +23 -23
- package/files/finalrelease +7 -7
- package/files/generate-ai-promo-video.js +1525 -0
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/files/scripts/setup-baseline-profile.js +262 -262
- package/files/take-screen-image.js +1418 -1284
- package/files/take-screen-video.js +25 -32
- package/package.json +15 -15
- package/scripts/sync-files.js +103 -103
- package/scripts/uninstall.js +109 -109
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//--duration 0 //30,120 (0 is used "Enter" key to stop)
|
|
5
5
|
//--countdown 0//0,5,10
|
|
6
6
|
//--name test-name
|
|
7
|
-
//--profiles youtube,non-spatial-xr,
|
|
7
|
+
//--profiles youtube,non-spatial-xr,amazon
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -17,8 +17,6 @@ const projectDirectory = scriptDirectory;
|
|
|
17
17
|
const temporaryDirectory = path.join(projectDirectory, 'agent-temp', 'store-video');
|
|
18
18
|
const outputDirectory = path.join(projectDirectory, 'Auto-Screenshot', 'Video', 'Output');
|
|
19
19
|
const deviceRecordingPath = '/sdcard/codeplay_store_video.mp4';
|
|
20
|
-
const ffmpegFallbackDirectory = 'W:\\Tools\\ffmpeg\\bin';
|
|
21
|
-
const scrcpyFallbackPath = 'W:\\Tools\\scrcpy\\scrcpy.exe';
|
|
22
20
|
const capacitorConfigPath = path.join(projectDirectory, 'capacitor.config.json');
|
|
23
21
|
|
|
24
22
|
const videoProfiles = {
|
|
@@ -40,15 +38,6 @@ const videoProfiles = {
|
|
|
40
38
|
videoBitrate: '12M',
|
|
41
39
|
h264Level: '5.1',
|
|
42
40
|
},
|
|
43
|
-
samsung: {
|
|
44
|
-
label: 'Samsung Galaxy Store YouTube preview',
|
|
45
|
-
directory: 'Samsung',
|
|
46
|
-
fileSuffix: 'samsung',
|
|
47
|
-
width: 1920,
|
|
48
|
-
height: 1080,
|
|
49
|
-
videoBitrate: '8M',
|
|
50
|
-
h264Level: '4.2',
|
|
51
|
-
},
|
|
52
41
|
amazon: {
|
|
53
42
|
label: 'Amazon Appstore',
|
|
54
43
|
directory: 'Amazon',
|
|
@@ -94,16 +83,7 @@ function commandExists(command) {
|
|
|
94
83
|
}
|
|
95
84
|
|
|
96
85
|
function getExecutable(command) {
|
|
97
|
-
|
|
98
|
-
return command;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const fallbackPath = path.join(ffmpegFallbackDirectory, `${command}.exe`);
|
|
102
|
-
if (fs.existsSync(fallbackPath)) {
|
|
103
|
-
return fallbackPath;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return '';
|
|
86
|
+
return commandExists(command) ? command : '';
|
|
107
87
|
}
|
|
108
88
|
|
|
109
89
|
function wait(milliseconds) {
|
|
@@ -143,6 +123,17 @@ function getConnectedDevice() {
|
|
|
143
123
|
return devices[0];
|
|
144
124
|
}
|
|
145
125
|
|
|
126
|
+
function stopScreenRecording(recording) {
|
|
127
|
+
// Allocate a remote pseudo-terminal so Ctrl+C is delivered as an interrupt
|
|
128
|
+
// to screenrecord. Without a PTY, adb treats it as ordinary pipe data.
|
|
129
|
+
try {
|
|
130
|
+
recording.child.stdin.write('\u0003');
|
|
131
|
+
recording.child.stdin.end();
|
|
132
|
+
} catch {
|
|
133
|
+
// The adb shell may already have closed its input stream.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
146
137
|
function sanitizeName(value) {
|
|
147
138
|
const name = String(value || '')
|
|
148
139
|
.trim()
|
|
@@ -170,7 +161,7 @@ function parseArguments() {
|
|
|
170
161
|
input: '',
|
|
171
162
|
list: false,
|
|
172
163
|
name: '',
|
|
173
|
-
profiles: 'youtube,non-spatial-xr,
|
|
164
|
+
profiles: 'youtube,non-spatial-xr,amazon',
|
|
174
165
|
spatialInput: '',
|
|
175
166
|
};
|
|
176
167
|
|
|
@@ -305,8 +296,7 @@ function waitForManualStop(recordingCompletion, duration) {
|
|
|
305
296
|
}
|
|
306
297
|
|
|
307
298
|
function getScrcpyCommand() {
|
|
308
|
-
|
|
309
|
-
return fs.existsSync(scrcpyFallbackPath) ? scrcpyFallbackPath : '';
|
|
299
|
+
return commandExists('scrcpy') ? 'scrcpy' : '';
|
|
310
300
|
}
|
|
311
301
|
|
|
312
302
|
async function recordConnectedDevice(options, destinationPath) {
|
|
@@ -337,7 +327,7 @@ async function recordConnectedDevice(options, destinationPath) {
|
|
|
337
327
|
const scrcpyCommand = getScrcpyCommand();
|
|
338
328
|
if (!scrcpyCommand) {
|
|
339
329
|
throw new Error(
|
|
340
|
-
'Audio recording requires scrcpy. Install
|
|
330
|
+
'Audio recording requires scrcpy. Install scrcpy and add it to PATH.',
|
|
341
331
|
);
|
|
342
332
|
}
|
|
343
333
|
|
|
@@ -356,11 +346,11 @@ async function recordConnectedDevice(options, destinationPath) {
|
|
|
356
346
|
} else {
|
|
357
347
|
recording = runAsync('adb', [
|
|
358
348
|
'-s', deviceId,
|
|
359
|
-
'shell', 'screenrecord',
|
|
349
|
+
'shell', '-t', 'screenrecord',
|
|
360
350
|
'--bit-rate', '12000000',
|
|
361
351
|
'--time-limit', String(duration),
|
|
362
352
|
deviceRecordingPath,
|
|
363
|
-
]);
|
|
353
|
+
], { stdio: ['pipe', 'inherit', 'inherit'] });
|
|
364
354
|
}
|
|
365
355
|
|
|
366
356
|
let manualStopRequested = false;
|
|
@@ -376,16 +366,19 @@ async function recordConnectedDevice(options, destinationPath) {
|
|
|
376
366
|
'shell', 'pkill', '-TERM', '-f', 'com.genymobile.scrcpy.Server',
|
|
377
367
|
]);
|
|
378
368
|
} else {
|
|
379
|
-
|
|
369
|
+
stopScreenRecording(recording);
|
|
380
370
|
}
|
|
381
371
|
} else if (stopReason === 'maximum-duration') {
|
|
382
372
|
console.log(`Safety maximum reached after ${duration} seconds.`);
|
|
383
373
|
}
|
|
384
374
|
|
|
385
|
-
|
|
375
|
+
if (manualStopRequested) {
|
|
376
|
+
// Vendor recorder services can leave adb.exe waiting after the recording
|
|
377
|
+
// file has already been finalized. Give the device a moment, but do not
|
|
378
|
+
// block the pull forever on that wrapper process.
|
|
379
|
+
wait(2000);
|
|
380
|
+
} else {
|
|
386
381
|
await recording.completion;
|
|
387
|
-
} catch (error) {
|
|
388
|
-
if (!manualStopRequested) throw error;
|
|
389
382
|
}
|
|
390
383
|
|
|
391
384
|
if (audio === 'without') {
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "codeplay-common",
|
|
3
|
-
"version": "4.3.
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "codeplay-common",
|
|
3
|
+
"version": "4.3.7",
|
|
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
|
+
}
|
package/scripts/sync-files.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
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
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
16
|
-
|
|
17
|
-
function copyFolderSync(source, destination) {
|
|
18
|
-
try {
|
|
19
|
-
fs.cpSync(source, destination, { recursive: true });
|
|
20
|
-
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Copy all files from `common-build-files/files/` to the project root
|
|
27
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
28
|
-
const sourcePath = path.join(commonBuildPath, file);
|
|
29
|
-
const destPath = path.join(projectRoot, file);
|
|
30
|
-
|
|
31
|
-
if (fs.statSync(sourcePath).isDirectory()) {
|
|
32
|
-
copyFolderSync(sourcePath, destPath);
|
|
33
|
-
} else {
|
|
34
|
-
try {
|
|
35
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
36
|
-
process.stdout.write(`✅ Copied file: ${file}\n`);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
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
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
16
|
+
|
|
17
|
+
function copyFolderSync(source, destination) {
|
|
18
|
+
try {
|
|
19
|
+
fs.cpSync(source, destination, { recursive: true });
|
|
20
|
+
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Copy all files from `common-build-files/files/` to the project root
|
|
27
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
28
|
+
const sourcePath = path.join(commonBuildPath, file);
|
|
29
|
+
const destPath = path.join(projectRoot, file);
|
|
30
|
+
|
|
31
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
32
|
+
copyFolderSync(sourcePath, destPath);
|
|
33
|
+
} else {
|
|
34
|
+
try {
|
|
35
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
36
|
+
process.stdout.write(`✅ Copied file: ${file}\n`);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
43
|
// Function to get the latest versioned file from files/buildCodeplay
|
|
44
|
-
function getLatestFile(prefix) {
|
|
45
|
-
if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
|
|
46
|
-
|
|
47
|
-
const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
|
|
48
|
-
if (files.length === 0) return null;
|
|
49
|
-
files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
50
|
-
return files[0];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Detect latest script versions
|
|
54
|
-
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
55
|
-
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
56
|
-
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
57
|
-
|
|
58
|
-
const latestPackageIdModification = getLatestFile("packageidBaseModification-");
|
|
59
|
-
const baselineProfileSetupScript = "node scripts/setup-baseline-profile.js";
|
|
60
|
-
const baselineProfileGenerateScript = "cd android && gradlew.bat :app:generateBaselineProfile --console=plain";
|
|
61
|
-
|
|
62
|
-
function appendIfMissing(base, suffix) {
|
|
63
|
-
if (!suffix) return base;
|
|
64
|
-
if (!base || typeof base !== "string") return suffix;
|
|
65
|
-
if (base.includes(suffix)) return base;
|
|
66
|
-
return `${base} && ${suffix}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Ensure scripts object exists
|
|
71
|
-
packageJson.scripts = packageJson.scripts || {};
|
|
72
|
-
|
|
73
|
-
// Update or add necessary scripts
|
|
74
|
-
if (latestCodeplayBuild) {
|
|
75
|
-
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
76
|
-
}
|
|
77
|
-
if (latestSplashScreen && latestSplashAnimation) {
|
|
78
|
-
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
79
|
-
`node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation} && node buildCodeplay/manifestModification.js`,
|
|
80
|
-
baselineProfileSetupScript
|
|
81
|
-
);
|
|
82
|
-
//node buildCodeplay/ios-emi-admob-modification.js &&
|
|
83
|
-
} else if (packageJson.scripts["capacitor:sync:after"]) {
|
|
84
|
-
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
85
|
-
packageJson.scripts["capacitor:sync:after"],
|
|
86
|
-
baselineProfileSetupScript
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
packageJson.scripts["baseline-profile:setup"] = baselineProfileSetupScript;
|
|
90
|
-
packageJson.scripts["baseline-profile:generate"] = baselineProfileGenerateScript;
|
|
91
|
-
|
|
92
|
-
packageJson.scripts["ionic:build"] = "npm run build";
|
|
93
|
-
packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite";
|
|
94
|
-
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
95
|
-
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
96
|
-
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
97
|
-
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
98
|
-
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
99
|
-
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
100
|
-
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
101
|
-
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
102
|
-
// Save changes
|
|
103
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
104
|
-
process.stdout.write("✅ package.json updated!\n");
|
|
44
|
+
function getLatestFile(prefix) {
|
|
45
|
+
if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
|
|
46
|
+
|
|
47
|
+
const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
|
|
48
|
+
if (files.length === 0) return null;
|
|
49
|
+
files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
50
|
+
return files[0];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Detect latest script versions
|
|
54
|
+
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
55
|
+
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
56
|
+
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
57
|
+
|
|
58
|
+
const latestPackageIdModification = getLatestFile("packageidBaseModification-");
|
|
59
|
+
const baselineProfileSetupScript = "node scripts/setup-baseline-profile.js";
|
|
60
|
+
const baselineProfileGenerateScript = "cd android && gradlew.bat :app:generateBaselineProfile --console=plain";
|
|
61
|
+
|
|
62
|
+
function appendIfMissing(base, suffix) {
|
|
63
|
+
if (!suffix) return base;
|
|
64
|
+
if (!base || typeof base !== "string") return suffix;
|
|
65
|
+
if (base.includes(suffix)) return base;
|
|
66
|
+
return `${base} && ${suffix}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// Ensure scripts object exists
|
|
71
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
72
|
+
|
|
73
|
+
// Update or add necessary scripts
|
|
74
|
+
if (latestCodeplayBuild) {
|
|
75
|
+
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
76
|
+
}
|
|
77
|
+
if (latestSplashScreen && latestSplashAnimation) {
|
|
78
|
+
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
79
|
+
`node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation} && node buildCodeplay/manifestModification.js`,
|
|
80
|
+
baselineProfileSetupScript
|
|
81
|
+
);
|
|
82
|
+
//node buildCodeplay/ios-emi-admob-modification.js &&
|
|
83
|
+
} else if (packageJson.scripts["capacitor:sync:after"]) {
|
|
84
|
+
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
85
|
+
packageJson.scripts["capacitor:sync:after"],
|
|
86
|
+
baselineProfileSetupScript
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
packageJson.scripts["baseline-profile:setup"] = baselineProfileSetupScript;
|
|
90
|
+
packageJson.scripts["baseline-profile:generate"] = baselineProfileGenerateScript;
|
|
91
|
+
|
|
92
|
+
packageJson.scripts["ionic:build"] = "npm run build";
|
|
93
|
+
packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite";
|
|
94
|
+
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
95
|
+
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
96
|
+
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
97
|
+
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
98
|
+
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
99
|
+
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
100
|
+
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
101
|
+
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
102
|
+
// Save changes
|
|
103
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
104
|
+
process.stdout.write("✅ package.json updated!\n");
|
package/scripts/uninstall.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
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
|
-
const baselineProfileSetupScript = path.join(projectRoot, "scripts", "setup-baseline-profile.js");
|
|
16
|
-
const baselineProfileBackup = path.join(projectRoot, "baselineProfiles", "baseline-prof.txt");
|
|
17
|
-
|
|
18
|
-
const isAgentInstructionAsset = (file) => {
|
|
19
|
-
const normalizedName = file.toLowerCase();
|
|
20
|
-
return normalizedName === "agents" || normalizedName === "agents.md";
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
24
|
-
|
|
25
|
-
const removeDirectory = (dirPath) => {
|
|
26
|
-
if (fs.existsSync(dirPath)) {
|
|
27
|
-
fs.readdirSync(dirPath).forEach(file => {
|
|
28
|
-
const currentPath = path.join(dirPath, file);
|
|
29
|
-
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
30
|
-
removeDirectory(currentPath);
|
|
31
|
-
} else {
|
|
32
|
-
fs.unlinkSync(currentPath);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
fs.rmdirSync(dirPath);
|
|
36
|
-
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
removeDirectory(splashXmlPath);
|
|
41
|
-
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
42
|
-
|
|
43
|
-
// Step 1: Find all matching files in the project directory
|
|
44
|
-
const filePatternsToRemove = [
|
|
45
|
-
/^add-splash-screen-.*$/,
|
|
46
|
-
/^setSplashAnimation-.*$/,
|
|
47
|
-
/^codeplayBeforeBuild-.*$/,
|
|
48
|
-
/^modify-plugin-xml\.xml$/,
|
|
49
|
-
/^finalrelease.*$/,
|
|
50
|
-
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
51
|
-
/^\.env\.storeid[1-7]$/,
|
|
52
|
-
/^modify-plugin-xml\.js$/
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const filesInProject = fs.readdirSync(projectRoot);
|
|
56
|
-
|
|
57
|
-
filesInProject.forEach(file => {
|
|
58
|
-
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
59
|
-
const filePath = path.join(projectRoot, file);
|
|
60
|
-
try {
|
|
61
|
-
fs.unlinkSync(filePath);
|
|
62
|
-
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Remove files and folders listed in commonBuildPath
|
|
70
|
-
if (fs.existsSync(commonBuildPath)) {
|
|
71
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
72
|
-
const destPath = path.join(projectRoot, file);
|
|
73
|
-
if (file === "scripts" || isAgentInstructionAsset(file)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (fs.existsSync(destPath)) {
|
|
77
|
-
try {
|
|
78
|
-
if (fs.lstatSync(destPath).isDirectory()) {
|
|
79
|
-
removeDirectory(destPath);
|
|
80
|
-
} else {
|
|
81
|
-
fs.unlinkSync(destPath);
|
|
82
|
-
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
83
|
-
}
|
|
84
|
-
} catch (error) {
|
|
85
|
-
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (fs.existsSync(baselineProfileSetupScript)) {
|
|
92
|
-
try {
|
|
93
|
-
fs.unlinkSync(baselineProfileSetupScript);
|
|
94
|
-
process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
|
|
95
|
-
} catch (error) {
|
|
96
|
-
process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (fs.existsSync(baselineProfileBackup)) {
|
|
101
|
-
try {
|
|
102
|
-
fs.unlinkSync(baselineProfileBackup);
|
|
103
|
-
process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
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
|
+
const baselineProfileSetupScript = path.join(projectRoot, "scripts", "setup-baseline-profile.js");
|
|
16
|
+
const baselineProfileBackup = path.join(projectRoot, "baselineProfiles", "baseline-prof.txt");
|
|
17
|
+
|
|
18
|
+
const isAgentInstructionAsset = (file) => {
|
|
19
|
+
const normalizedName = file.toLowerCase();
|
|
20
|
+
return normalizedName === "agents" || normalizedName === "agents.md";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
24
|
+
|
|
25
|
+
const removeDirectory = (dirPath) => {
|
|
26
|
+
if (fs.existsSync(dirPath)) {
|
|
27
|
+
fs.readdirSync(dirPath).forEach(file => {
|
|
28
|
+
const currentPath = path.join(dirPath, file);
|
|
29
|
+
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
30
|
+
removeDirectory(currentPath);
|
|
31
|
+
} else {
|
|
32
|
+
fs.unlinkSync(currentPath);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
fs.rmdirSync(dirPath);
|
|
36
|
+
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
removeDirectory(splashXmlPath);
|
|
41
|
+
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
42
|
+
|
|
43
|
+
// Step 1: Find all matching files in the project directory
|
|
44
|
+
const filePatternsToRemove = [
|
|
45
|
+
/^add-splash-screen-.*$/,
|
|
46
|
+
/^setSplashAnimation-.*$/,
|
|
47
|
+
/^codeplayBeforeBuild-.*$/,
|
|
48
|
+
/^modify-plugin-xml\.xml$/,
|
|
49
|
+
/^finalrelease.*$/,
|
|
50
|
+
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
51
|
+
/^\.env\.storeid[1-7]$/,
|
|
52
|
+
/^modify-plugin-xml\.js$/
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const filesInProject = fs.readdirSync(projectRoot);
|
|
56
|
+
|
|
57
|
+
filesInProject.forEach(file => {
|
|
58
|
+
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
59
|
+
const filePath = path.join(projectRoot, file);
|
|
60
|
+
try {
|
|
61
|
+
fs.unlinkSync(filePath);
|
|
62
|
+
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Remove files and folders listed in commonBuildPath
|
|
70
|
+
if (fs.existsSync(commonBuildPath)) {
|
|
71
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
72
|
+
const destPath = path.join(projectRoot, file);
|
|
73
|
+
if (file === "scripts" || isAgentInstructionAsset(file)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (fs.existsSync(destPath)) {
|
|
77
|
+
try {
|
|
78
|
+
if (fs.lstatSync(destPath).isDirectory()) {
|
|
79
|
+
removeDirectory(destPath);
|
|
80
|
+
} else {
|
|
81
|
+
fs.unlinkSync(destPath);
|
|
82
|
+
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (fs.existsSync(baselineProfileSetupScript)) {
|
|
92
|
+
try {
|
|
93
|
+
fs.unlinkSync(baselineProfileSetupScript);
|
|
94
|
+
process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (fs.existsSync(baselineProfileBackup)) {
|
|
101
|
+
try {
|
|
102
|
+
fs.unlinkSync(baselineProfileBackup);
|
|
103
|
+
process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
process.stdout.write("✅ Uninstall cleanup complete!\n");
|