@robylon/react-native-sdk 2.0.21-staging.3 → 2.0.22-dev.0

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.
Files changed (71) hide show
  1. package/lib/commonjs/Chatbotsdk.js +1 -1
  2. package/lib/commonjs/Chatbotsdk.js.map +1 -1
  3. package/lib/commonjs/constants.js +1 -1
  4. package/lib/commonjs/constants.js.map +1 -1
  5. package/lib/commonjs/openChatbot.js.map +1 -1
  6. package/lib/commonjs/version.js +1 -1
  7. package/lib/commonjs/versions/version.dev.js +1 -1
  8. package/lib/module/Chatbotsdk.js +1 -1
  9. package/lib/module/Chatbotsdk.js.map +1 -1
  10. package/lib/module/constants.js +1 -1
  11. package/lib/module/constants.js.map +1 -1
  12. package/lib/module/openChatbot.js +1 -2
  13. package/lib/module/version.js +1 -1
  14. package/lib/module/versions/version.dev.js +1 -1
  15. package/lib/typescript/version.d.ts +1 -1
  16. package/lib/typescript/version.d.ts.map +1 -1
  17. package/lib/typescript/versions/version.dev.d.ts +1 -1
  18. package/package.json +2 -2
  19. package/usage/react-native-ios-docs.md +185 -0
  20. package/.npmignore.development +0 -18
  21. package/.npmignore.production +0 -8
  22. package/.npmignore.staging +0 -7
  23. package/babel.config.js +0 -17
  24. package/scripts/create-branch.js +0 -577
  25. package/scripts/create-version-tag.js +0 -29
  26. package/scripts/get-next-version.js +0 -29
  27. package/scripts/husky-setup.js +0 -32
  28. package/scripts/prevent-direct-branch.js +0 -37
  29. package/scripts/publish-version.js +0 -13
  30. package/scripts/release.js +0 -77
  31. package/scripts/setup-git-hooks.js +0 -18
  32. package/scripts/update-version.js +0 -28
  33. package/scripts/validate-branch-name.sh +0 -65
  34. package/scripts/validate-publish.js +0 -48
  35. package/src/Chatbotsdk.tsx +0 -782
  36. package/src/FloatingButton/launchers/ImageLauncher.tsx +0 -75
  37. package/src/FloatingButton/launchers/TextLauncher.tsx +0 -84
  38. package/src/FloatingButton/launchers/TextualImageLauncher.tsx +0 -133
  39. package/src/FloatingButton.tsx +0 -97
  40. package/src/LoadingIndicator.tsx +0 -11
  41. package/src/Toast.tsx +0 -65
  42. package/src/components/DebugButton.tsx +0 -46
  43. package/src/components/ErrorBoundary.tsx +0 -38
  44. package/src/config.ts +0 -4
  45. package/src/constants/errorConstants.ts +0 -21
  46. package/src/constants/fontStyles.ts +0 -3
  47. package/src/constants.ts +0 -4
  48. package/src/global.d.ts +0 -11
  49. package/src/hooks/useChatbotEvents.ts +0 -93
  50. package/src/index.tsx +0 -10
  51. package/src/openChatbot.ts +0 -11
  52. package/src/openChatbot.tsx +0 -0
  53. package/src/services/ErrorTrackingService.ts +0 -217
  54. package/src/types/events.ts +0 -25
  55. package/src/types/react-native-flipper-performance-plugin.d.ts +0 -3
  56. package/src/types/react-native-globals.d.ts +0 -10
  57. package/src/utils/animations.ts +0 -120
  58. package/src/utils/colorUtils.ts +0 -35
  59. package/src/utils/cookieUtils.ts +0 -7
  60. package/src/utils/debugConfig.ts +0 -56
  61. package/src/utils/debugMenu.ts +0 -14
  62. package/src/utils/errorHandler.ts +0 -58
  63. package/src/utils/logger.ts +0 -14
  64. package/src/utils/systemInfo.ts +0 -84
  65. package/src/utils/webViewStorage.ts +0 -62
  66. package/src/version.ts +0 -2
  67. package/src/versions/version.dev.ts +0 -2
  68. package/src/versions/version.production.ts +0 -2
  69. package/src/versions/version.staging.ts +0 -2
  70. package/tsconfig.build.json +0 -16
  71. package/tsconfig.json +0 -26
@@ -1,577 +0,0 @@
1
- const { execSync } = require("child_process");
2
- const readline = require("readline");
3
- const semver = require("semver");
4
-
5
- const rl = readline.createInterface({
6
- input: process.stdin,
7
- output: process.stdout,
8
- });
9
-
10
- // Calculate the next patch version
11
- const getNextPatchVersion = (currentVersion) => {
12
- const versionParts = currentVersion.split(".");
13
- const nextPatch = parseInt(versionParts[2]) + 1;
14
- return `${versionParts[0]}.${versionParts[1]}.${nextPatch}`;
15
- };
16
-
17
- // Validate branch name format
18
- const isValidFeatureName = (name) => /^[a-z0-9-]+$/.test(name);
19
-
20
- // Get the latest version from remote main
21
- const getLatestMainVersion = () => {
22
- try {
23
- // Fetch latest from remote
24
- execSync("git fetch origin main --quiet");
25
-
26
- // Get package.json content from remote main
27
- const remotePackageJson = execSync(
28
- "git show origin/main:package.json"
29
- ).toString();
30
-
31
- return JSON.parse(remotePackageJson).version;
32
- } catch (error) {
33
- throw new Error(
34
- "Failed to get version from remote main. Ensure you have internet connection and repository access."
35
- );
36
- }
37
- };
38
-
39
- // Get target version for new branches
40
- const getTargetVersion = () => {
41
- try {
42
- // Get current branch
43
- const currentBranch = execSync("git rev-parse --abbrev-ref HEAD")
44
- .toString()
45
- .trim();
46
-
47
- // If we're on a release branch, use its version for new features
48
- if (currentBranch.startsWith("release/v")) {
49
- return currentBranch.split("/v")[1];
50
- }
51
-
52
- // Otherwise, use next version from main
53
- const mainVersion = getLatestMainVersion();
54
- return getNextPatchVersion(mainVersion);
55
- } catch (error) {
56
- throw new Error("Failed to determine target version");
57
- }
58
- };
59
-
60
- // Validate that we're not creating conflicting branches
61
- const validateVersionAvailability = async (targetVersion) => {
62
- try {
63
- // Get all remote branches
64
- const remoteBranches = execSync("git ls-remote --heads origin")
65
- .toString()
66
- .split("\n")
67
- .filter(Boolean)
68
- .map((line) => line.split("/").slice(3).join("/"));
69
-
70
- // Check for existing feature branches with same version
71
- const conflictingBranches = remoteBranches.filter((branch) =>
72
- branch.startsWith(`feature/v${targetVersion}/`)
73
- );
74
-
75
- if (conflictingBranches.length > 0) {
76
- console.log(
77
- "\n⚠️ Warning: The following branches already exist for version",
78
- targetVersion
79
- );
80
- conflictingBranches.forEach((branch) => console.log(` - ${branch}`));
81
-
82
- const proceed = await new Promise((resolve) =>
83
- rl.question("\nDo you want to proceed anyway? (y/N): ", resolve)
84
- );
85
-
86
- if (proceed.toLowerCase() !== "y") {
87
- throw new Error("Operation cancelled by user");
88
- }
89
- }
90
- } catch (error) {
91
- if (error.message === "Operation cancelled by user") {
92
- throw error;
93
- }
94
- throw new Error("Failed to validate version availability");
95
- }
96
- };
97
-
98
- // Calculate the next version based on type
99
- const getNextVersion = (currentVersion, type) => {
100
- // Strip any pre-release tags (e.g., -staging.0) and split version
101
- const baseVersion = currentVersion.split("-")[0];
102
- const [major, minor, patch] = baseVersion.split(".").map(Number);
103
-
104
- switch (type) {
105
- case "major":
106
- return `${major + 1}.0.0`;
107
- case "minor":
108
- return `${major}.${minor + 1}.0`;
109
- case "patch":
110
- return `${major}.${minor}.${patch + 1}`;
111
- default:
112
- throw new Error("Invalid version type");
113
- }
114
- };
115
-
116
- // Get unmerged release branches
117
- const getUnmergedReleaseBranches = () => {
118
- try {
119
- return execSync("git branch -r")
120
- .toString()
121
- .split("\n")
122
- .filter((branch) => branch.includes("origin/release/v"))
123
- .map((branch) => branch.trim())
124
- .filter((branch) => {
125
- const version = branch.split("/v")[1];
126
- return semver.gt(version, getLatestMainVersion());
127
- });
128
- } catch (error) {
129
- return [];
130
- }
131
- };
132
-
133
- // Get unmerged feature branches for a version
134
- const getUnmergedFeatureBranches = (version) => {
135
- return execSync("git branch -r")
136
- .toString()
137
- .split("\n")
138
- .filter((branch) => branch.includes(`feature/v${version}/`))
139
- .map((branch) => branch.trim());
140
- };
141
-
142
- // Get repository URL for PR creation
143
- const getRepoUrl = () => {
144
- const remoteUrl = execSync("git remote get-url origin").toString().trim();
145
- return remoteUrl
146
- .replace(/\.git$/, "")
147
- .replace("git@github.com:", "https://github.com/");
148
- };
149
-
150
- // Add this new function near the top with other helper functions
151
- const updatePackageVersion = async (version, branchName) => {
152
- try {
153
- // Update version without creating git tag
154
- execSync(`npm version ${version} --no-git-tag-version`);
155
- execSync(`git add package.json package-lock.json`);
156
- execSync(`git commit -m "chore: update version to ${version}"`);
157
-
158
- // Push changes
159
- console.log("\n📡 Pushing version update to remote...");
160
- execSync(`git push origin ${branchName}`);
161
- } catch (error) {
162
- throw new Error(`Failed to update version: ${error.message}`);
163
- }
164
- };
165
-
166
- const createBranch = async () => {
167
- try {
168
- // Set environment variable to allow branch creation
169
- process.env.BRANCH_CREATION_ALLOWED = "true";
170
-
171
- // Ensure we have latest changes
172
- console.log("\n📡 Fetching latest changes...");
173
- execSync("git fetch origin --quiet");
174
-
175
- // Get target version for new branches
176
- const targetVersion = getTargetVersion();
177
- const localVersion = require("../package.json").version;
178
- const remoteMainVersion = getLatestMainVersion();
179
-
180
- // Only check if we're on main
181
- const currentBranch = execSync("git rev-parse --abbrev-ref HEAD")
182
- .toString()
183
- .trim();
184
- if (currentBranch === "main") {
185
- if (semver.lt(localVersion, remoteMainVersion)) {
186
- throw new Error(
187
- `Your local branch (${localVersion}) is behind remote main (${remoteMainVersion}). ` +
188
- `Please pull latest changes first: git pull origin main`
189
- );
190
- }
191
- }
192
-
193
- console.log("\nCurrent version:", localVersion);
194
-
195
- console.log("\nSelect branch type:");
196
- console.log("1. Feature branch");
197
- console.log("2. Release branch");
198
- console.log("3. Hotfix branch");
199
-
200
- const answer = await new Promise((resolve) =>
201
- rl.question("\nEnter your choice (1, 2 or 3): ", resolve)
202
- );
203
-
204
- if (answer === "1") {
205
- // Feature branch
206
- await validateVersionAvailability(targetVersion);
207
-
208
- const featureName = await new Promise((resolve) =>
209
- rl.question("\nEnter feature name (use-kebab-case): ", resolve)
210
- );
211
-
212
- if (!isValidFeatureName(featureName)) {
213
- throw new Error(
214
- "Invalid feature name. Use kebab-case (e.g., 'add-chat-widget')"
215
- );
216
- }
217
-
218
- const branchName = `feature/v${targetVersion}/${featureName}`;
219
- execSync(`git checkout -b ${branchName}`);
220
- console.log(`\n✅ Successfully created feature branch: ${branchName}`);
221
- } else if (answer === "2") {
222
- // Release branch
223
- console.log("\nCreating release branch for next version...");
224
-
225
- const conflictedBranches = [];
226
-
227
- // Check for unmerged release branches first
228
- const unmergedReleases = getUnmergedReleaseBranches();
229
- if (unmergedReleases.length > 0) {
230
- console.log("\n⚠️ Unmerged release branches found:");
231
- unmergedReleases.forEach((branch, index) =>
232
- console.log(`${index + 1}. ${branch}`)
233
- );
234
-
235
- const proceed = await new Promise((resolve) =>
236
- rl.question(
237
- "\nWould you like to:\n" +
238
- "1. Add features to existing release\n" +
239
- "2. Cancel operation\n" +
240
- "\nEnter your choice (1 or 2): ",
241
- resolve
242
- )
243
- );
244
-
245
- if (proceed === "1") {
246
- const releaseChoice = await new Promise((resolve) =>
247
- rl.question("\nSelect release branch number: ", resolve)
248
- );
249
-
250
- const selectedRelease = unmergedReleases[parseInt(releaseChoice) - 1];
251
- if (!selectedRelease) {
252
- throw new Error("Invalid release branch selection");
253
- }
254
-
255
- const releaseVersion = selectedRelease.split("/v")[1];
256
- const unmergedFeatures = getUnmergedFeatureBranches(releaseVersion);
257
-
258
- if (unmergedFeatures.length === 0) {
259
- console.log(
260
- "\nNo unmerged feature branches found for this version."
261
- );
262
- return;
263
- }
264
-
265
- console.log("\nUnmerged feature branches:");
266
- unmergedFeatures.forEach((branch, index) =>
267
- console.log(`${index + 1}. ${branch}`)
268
- );
269
-
270
- const featureChoice = await new Promise((resolve) =>
271
- rl.question(
272
- "\nSelect features to merge (comma-separated numbers or 'all'): ",
273
- resolve
274
- )
275
- );
276
-
277
- // Checkout the release branch
278
- const releaseBranchName = selectedRelease.split("origin/")[1];
279
-
280
- // Check if branch exists locally
281
- const localBranches = execSync("git branch").toString();
282
- const branchExists = localBranches.includes(releaseBranchName);
283
-
284
- if (branchExists) {
285
- // If branch exists locally, just check it out
286
- execSync(`git checkout ${releaseBranchName}`);
287
- // Update to latest from remote
288
- execSync(`git fetch origin ${releaseBranchName}`);
289
- execSync(`git reset --hard origin/${releaseBranchName}`);
290
- } else {
291
- // If branch doesn't exist locally, create and track it
292
- execSync(`git fetch origin ${releaseBranchName}`);
293
- execSync(
294
- `git checkout -b ${releaseBranchName} origin/${releaseBranchName}`
295
- );
296
- }
297
-
298
- // Merge selected features
299
- const selectedFeatures =
300
- featureChoice.toLowerCase() === "all"
301
- ? unmergedFeatures
302
- : featureChoice
303
- .split(",")
304
- .map((num) => unmergedFeatures[parseInt(num.trim()) - 1])
305
- .filter(Boolean);
306
-
307
- for (const branch of selectedFeatures) {
308
- console.log(`\nMerging ${branch}...`);
309
- try {
310
- execSync(
311
- `git merge ${branch} --no-ff -m "Merge ${branch} into ${releaseBranchName}"`
312
- );
313
- } catch (error) {
314
- console.log(`\n⚠️ Merge conflict detected with ${branch}!`);
315
- execSync("git merge --abort");
316
- console.log(`\n⏩ Skipping ${branch} due to conflicts`);
317
- conflictedBranches.push(branch);
318
- }
319
- }
320
-
321
- // After all merges, show summary of conflicted branches
322
- if (conflictedBranches.length > 0) {
323
- const repoUrl = getRepoUrl();
324
- console.log("\n🚨 MERGE CONFLICTS DETECTED 🚨");
325
- console.log("=====================================");
326
- conflictedBranches.forEach((branch) => {
327
- const prUrl = `${repoUrl}/compare/${releaseBranchName}...${branch}?expand=1`;
328
- console.log(`\n❌ ${branch}`);
329
- console.log(`🔗 Create PR: ${prUrl}`);
330
- });
331
- console.log(
332
- "\n⚠️ ACTION REQUIRED: Please resolve conflicts and merge these branches manually ⚠️"
333
- );
334
- }
335
-
336
- // Show success message with merged/unmerged counts
337
- const mergedCount =
338
- selectedFeatures.length - conflictedBranches.length;
339
- console.log(
340
- `\n✅ Successfully merged ${mergedCount}/${selectedFeatures.length} branches`
341
- );
342
- if (conflictedBranches.length > 0) {
343
- console.log(
344
- `\n🚨 ATTENTION: ${conflictedBranches.length} branches require manual conflict resolution 🚨`
345
- );
346
- }
347
-
348
- return;
349
- }
350
-
351
- throw new Error(
352
- "Operation cancelled - please merge existing release first"
353
- );
354
- }
355
-
356
- // Ask for version type
357
- console.log("\nSelect version type:");
358
- console.log(`1. Major (${getNextVersion(localVersion, "major")})`);
359
- console.log(`2. Minor (${getNextVersion(localVersion, "minor")})`);
360
- console.log(`3. Patch (${getNextVersion(localVersion, "patch")})`);
361
-
362
- const versionType = await new Promise((resolve) =>
363
- rl.question("\nEnter your choice (1, 2 or 3): ", resolve)
364
- );
365
-
366
- let releaseVersion;
367
- switch (versionType) {
368
- case "1":
369
- releaseVersion = getNextVersion(localVersion, "major");
370
- break;
371
- case "2":
372
- releaseVersion = getNextVersion(localVersion, "minor");
373
- break;
374
- case "3":
375
- releaseVersion = getNextVersion(localVersion, "patch");
376
- break;
377
- default:
378
- throw new Error("Invalid version type selection");
379
- }
380
-
381
- console.log(`\nUpdating package.json version to ${releaseVersion}...`);
382
-
383
- // Create release branch
384
- const branchName = `release/v${releaseVersion}`;
385
-
386
- // Check if branch exists remotely
387
- const remoteBranches = execSync("git ls-remote --heads origin")
388
- .toString()
389
- .split("\n")
390
- .filter(Boolean)
391
- .map((line) => line.split("/").slice(2).join("/"));
392
-
393
- const branchExists = remoteBranches.includes(branchName);
394
-
395
- if (branchExists) {
396
- const proceed = await new Promise((resolve) =>
397
- rl.question(
398
- "\n⚠️ Release branch already exists remotely. Do you want to:\n" +
399
- "1. Create new branch with force push (overwrite remote)\n" +
400
- "2. Checkout existing branch and continue\n" +
401
- "3. Cancel operation\n" +
402
- "\nEnter your choice (1, 2 or 3): ",
403
- resolve
404
- )
405
- );
406
-
407
- switch (proceed) {
408
- case "1":
409
- // Continue with force push
410
- break;
411
- case "2":
412
- execSync(`git fetch origin ${branchName}`);
413
- execSync(`git checkout -b ${branchName} origin/${branchName}`);
414
- console.log(`\n✅ Checked out existing branch: ${branchName}`);
415
- return;
416
- default:
417
- throw new Error("Operation cancelled by user");
418
- }
419
- }
420
-
421
- execSync(`git checkout -b ${branchName}`);
422
-
423
- // Update version only during initial branch creation
424
- await updatePackageVersion(releaseVersion, branchName);
425
-
426
- // Get all feature branches for next version
427
- const featureBranches = execSync("git branch -r")
428
- .toString()
429
- .split("\n")
430
- .filter((branch) => branch.includes(`feature/v${releaseVersion}/`))
431
- .map((branch) => branch.trim());
432
-
433
- if (featureBranches.length === 0) {
434
- console.log("\n⚠️ No feature branches found for this version.");
435
- const proceed = await new Promise((resolve) =>
436
- rl.question("\nContinue without feature branches? (y/N): ", resolve)
437
- );
438
- if (proceed.toLowerCase() !== "y") {
439
- throw new Error("Operation cancelled by user");
440
- }
441
- } else {
442
- console.log("\nAvailable feature branches:");
443
- featureBranches.forEach((branch, index) =>
444
- console.log(`${index + 1}. ${branch}`)
445
- );
446
-
447
- const featureChoice = await new Promise((resolve) =>
448
- rl.question(
449
- "\nSelect features to include (comma-separated numbers or 'all' or 'none'): ",
450
- resolve
451
- )
452
- );
453
-
454
- // Treat empty input as "none"
455
- const choice = featureChoice.trim().toLowerCase();
456
- const isNoneOrEmpty = !choice || choice === "none";
457
-
458
- if (!isNoneOrEmpty) {
459
- const selectedFeatures =
460
- choice === "all"
461
- ? featureBranches
462
- : choice
463
- .split(",")
464
- .map((num) => featureBranches[parseInt(num.trim()) - 1])
465
- .filter(Boolean);
466
-
467
- // Validate that we have valid selections
468
- if (selectedFeatures.length === 0) {
469
- throw new Error(
470
- "No valid feature branches selected. Please try again"
471
- );
472
- }
473
-
474
- // Merge selected feature branches
475
- for (const branch of selectedFeatures) {
476
- console.log(`\nMerging ${branch}...`);
477
- try {
478
- execSync(
479
- `git merge ${branch} --no-ff -m "Merge ${branch} into ${branchName}"`
480
- );
481
- } catch (error) {
482
- console.log(`\n⚠️ Merge conflict detected with ${branch}!`);
483
- execSync("git merge --abort");
484
- console.log(`\n⏩ Skipping ${branch} due to conflicts`);
485
- conflictedBranches.push(branch);
486
- }
487
- }
488
-
489
- // After all merges, show summary of conflicted branches
490
- if (conflictedBranches.length > 0) {
491
- const repoUrl = getRepoUrl();
492
- console.log("\n🚨 MERGE CONFLICTS DETECTED 🚨");
493
- console.log("=====================================");
494
- conflictedBranches.forEach((branch) => {
495
- const prUrl = `${repoUrl}/compare/${branchName}...${branch}?expand=1`;
496
- console.log(`\n❌ ${branch}`);
497
- console.log(`🔗 Create PR: ${prUrl}`);
498
- });
499
- console.log(
500
- "\n⚠️ ACTION REQUIRED: Please resolve conflicts and merge these branches manually ⚠️"
501
- );
502
- }
503
-
504
- // Show success message with merged/unmerged counts
505
- const mergedCount =
506
- selectedFeatures.length - conflictedBranches.length;
507
- console.log(
508
- `\n✅ Successfully merged ${mergedCount}/${selectedFeatures.length} branches`
509
- );
510
- if (conflictedBranches.length > 0) {
511
- console.log(
512
- `\n🚨 ATTENTION: ${conflictedBranches.length} branches require manual conflict resolution 🚨`
513
- );
514
- }
515
- } else {
516
- console.log("\n📝 Creating release branch without features");
517
- }
518
- }
519
-
520
- // Push all changes to remote
521
- try {
522
- console.log("\n📡 Pushing final changes to remote...");
523
- execSync(`git push origin ${branchName}`);
524
- } catch (error) {
525
- throw new Error(
526
- `Failed to push final changes. Please push manually.\nError: ${error.message}`
527
- );
528
- }
529
-
530
- console.log(`\n✅ Successfully created release branch: ${branchName}`);
531
- console.log("\nNext steps:");
532
- console.log("1. Review and test the changes");
533
- console.log("2. Run 'npm run publish:production' when ready to release");
534
- } else if (answer === "3") {
535
- // Hotfix branch
536
- console.log("\nEnter the version to hotfix (e.g., 1.1.14):");
537
- const targetVersion = await new Promise((resolve) =>
538
- rl.question("\nVersion: ", resolve)
539
- );
540
-
541
- // Validate version format
542
- if (!/^\d+\.\d+\.\d+$/.test(targetVersion)) {
543
- throw new Error("Invalid version format. Use semver (e.g., 1.1.14)");
544
- }
545
-
546
- // Get patch number
547
- console.log("\nEnter patch number (e.g., 1 for first patch):");
548
- const patchNumber = await new Promise((resolve) =>
549
- rl.question("\nPatch number: ", resolve)
550
- );
551
-
552
- if (!/^\d+$/.test(patchNumber)) {
553
- throw new Error("Invalid patch number. Use a number (e.g., 1)");
554
- }
555
-
556
- const branchName = `hotfix/v${targetVersion}-patch.${patchNumber}`;
557
-
558
- // Checkout the tag first
559
- execSync(`git fetch --all --tags`);
560
- execSync(`git checkout v${targetVersion}`);
561
- execSync(`git checkout -b ${branchName}`);
562
-
563
- console.log(`\n✅ Successfully created hotfix branch: ${branchName}`);
564
- } else {
565
- throw new Error("Invalid choice. Please select 1, 2 or 3.");
566
- }
567
- } catch (error) {
568
- console.error("\n❌ Error:", error.message);
569
- } finally {
570
- // Clear the environment variable
571
- delete process.env.BRANCH_CREATION_ALLOWED;
572
-
573
- rl.close();
574
- }
575
- };
576
-
577
- createBranch();
@@ -1,29 +0,0 @@
1
- const { execSync } = require("child_process");
2
-
3
- const createVersionTag = () => {
4
- try {
5
- const { version } = require("../package.json");
6
- const tagName = `v${version}`;
7
-
8
- // Check if tag exists
9
- try {
10
- execSync(`git tag -l "${tagName}"`).toString().trim();
11
- console.log(`✅ Tag ${tagName} already exists, skipping tag creation`);
12
- return;
13
- } catch (error) {
14
- // Tag doesn't exist, create it
15
- try {
16
- execSync(`git tag -a ${tagName} -m "Release: ${tagName}"`);
17
- execSync(`git push origin ${tagName}`);
18
- console.log(`✅ Successfully created and pushed tag: ${tagName}`);
19
- } catch (tagError) {
20
- throw new Error(`Failed to create or push tag: ${tagError.message}`);
21
- }
22
- }
23
- } catch (error) {
24
- console.error("\n❌ Error creating tag:", error.message);
25
- process.exit(1);
26
- }
27
- };
28
-
29
- createVersionTag();
@@ -1,29 +0,0 @@
1
- const semver = require("semver");
2
- const { execSync } = require("child_process");
3
-
4
- function getNextVersion(publishType) {
5
- const { version } = require("../package.json");
6
-
7
- switch (publishType) {
8
- case "staging":
9
- return semver.inc(version, "prerelease", "staging");
10
- case "hotfix":
11
- return semver.inc(version, "prerelease", "patch");
12
- case "production":
13
- return semver.inc(version, "patch");
14
- default:
15
- throw new Error(`Invalid publish type: ${publishType}`);
16
- }
17
- }
18
-
19
- // If script is run directly
20
- if (require.main === module) {
21
- const publishType = process.argv[2];
22
- if (!publishType) {
23
- console.error("Please provide a publish type (staging|production|hotfix)");
24
- process.exit(1);
25
- }
26
- console.log(getNextVersion(publishType));
27
- }
28
-
29
- module.exports = getNextVersion;
@@ -1,32 +0,0 @@
1
- const { execSync } = require("child_process");
2
- const fs = require("fs");
3
- const path = require("path");
4
-
5
- // Initialize husky
6
- execSync("npx husky install");
7
-
8
- // Create .husky directory if it doesn't exist
9
- const huskyDir = path.join(__dirname, "../.husky");
10
- if (!fs.existsSync(huskyDir)) {
11
- fs.mkdirSync(huskyDir, { recursive: true });
12
- }
13
-
14
- // Create commit-msg hook
15
- const hookContent = `#!/bin/sh
16
-
17
- sh scripts/validate-branch-name.sh
18
- `;
19
-
20
- fs.writeFileSync(path.join(huskyDir, "commit-msg"), hookContent);
21
- fs.chmodSync(path.join(huskyDir, "commit-msg"), "755");
22
-
23
- // Create post-checkout hook to prevent direct branch creation
24
- const postCheckoutContent = `#!/bin/sh
25
-
26
- node scripts/prevent-direct-branch.js
27
- `;
28
-
29
- fs.writeFileSync(path.join(huskyDir, "post-checkout"), postCheckoutContent);
30
- fs.chmodSync(path.join(huskyDir, "post-checkout"), "755");
31
-
32
- console.log("Husky hooks installed successfully!");