@wavemaker-ai/wm-reactnative-cli 1.0.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 (39) hide show
  1. package/README.md +236 -0
  2. package/assets/CLI-EnvironmentVariable.png +0 -0
  3. package/assets/EnvironmentVariable.png +0 -0
  4. package/assets/EnvironmentVariable1.png +0 -0
  5. package/files/ui-build.js +331 -0
  6. package/index.js +381 -0
  7. package/package.json +39 -0
  8. package/src/android.js +479 -0
  9. package/src/command.js +552 -0
  10. package/src/config.js +11 -0
  11. package/src/custom-logger/progress-bar.js +97 -0
  12. package/src/custom-logger/steps.js +117 -0
  13. package/src/custom-logger/task-logger.js +147 -0
  14. package/src/exec.js +73 -0
  15. package/src/expo-launcher.js +596 -0
  16. package/src/ios.js +517 -0
  17. package/src/logger.js +104 -0
  18. package/src/mobileprovision-parse/index.js +72 -0
  19. package/src/project-sync.service.js +390 -0
  20. package/src/requirements.js +250 -0
  21. package/src/utils.js +100 -0
  22. package/src/web-preview-launcher.js +548 -0
  23. package/src/zip.js +19 -0
  24. package/templates/embed/android/ReactNativeAppFragment.java +78 -0
  25. package/templates/embed/android/SplashScreenReactActivityLifecycleListener.kt +41 -0
  26. package/templates/embed/android/fragment_react_native_app.xml +14 -0
  27. package/templates/embed/ios/ReactNativeView.h +12 -0
  28. package/templates/embed/ios/ReactNativeView.m +59 -0
  29. package/templates/embed/ios/ReactNativeView.swift +53 -0
  30. package/templates/expo-camera-patch/useWebQRScanner.js +100 -0
  31. package/templates/ios-build-patch/podFIlePostInstall.js +72 -0
  32. package/templates/package/packageLock.json +14334 -0
  33. package/templates/wm-rn-runtime/App.js +479 -0
  34. package/templates/wm-rn-runtime/App.navigator.js +109 -0
  35. package/test.js +0 -0
  36. package/tools-site/index.html.template +17 -0
  37. package/tools-site/page_background.svg +99 -0
  38. package/tools-site/qrcode.js +614 -0
  39. package/tools-site/styles.css +39 -0
@@ -0,0 +1,117 @@
1
+ const previewSteps = [
2
+ {
3
+ step: 1,
4
+ start: "Setting up directories",
5
+ stop: "",
6
+ succeed: "Setup directories finished",
7
+ fail: "Setup directories failed",
8
+ info: "",
9
+ warn: "",
10
+ total: 1,
11
+ },
12
+ {
13
+ step: 2,
14
+ start: "Authenticating user",
15
+ stop: "",
16
+ succeed: "Authentication successful",
17
+ fail: "Authentication failed",
18
+ info: "",
19
+ warn: "",
20
+ total: 1,
21
+ },
22
+ {
23
+ step: 3,
24
+ start: "Downloading project",
25
+ stop: "",
26
+ succeed: "Project downloaded",
27
+ fail: "Project download failed",
28
+ info: "",
29
+ warn: "",
30
+ total: 5
31
+ },
32
+ {
33
+ step: 4,
34
+ start: "Transpiling project",
35
+ stop: "",
36
+ succeed: "Project transpiled successfully",
37
+ fail: "Transpiling project failed",
38
+ info: "",
39
+ warn: "",
40
+ total: 6
41
+ },
42
+ {
43
+ step: 5,
44
+ start: "Installing dependencies",
45
+ stop: "",
46
+ succeed: "Dependencies installed",
47
+ fail: "Dependencies installation failed",
48
+ info: "",
49
+ warn: "",
50
+ total: 4
51
+ },
52
+ ];
53
+
54
+
55
+ const androidBuildSteps = [
56
+ {
57
+ step: 1,
58
+ start: "Setting up build directories",
59
+ stop: "",
60
+ succeed: "Project directories successfully set up.",
61
+ fail: "Failed to set up project directories.",
62
+ info: "",
63
+ warn: "",
64
+ total: 6
65
+ },
66
+ {
67
+ step: 2,
68
+ start: "Verifying prerequisites...",
69
+ stop: "",
70
+ succeed: "All required prerequisites are met.",
71
+ fail: "Missing or incompatible prerequisites detected.",
72
+ info: "",
73
+ warn: "",
74
+ total: 2
75
+ },
76
+ {
77
+ step: 3,
78
+ start: "Installing dependencies...",
79
+ stop: "",
80
+ succeed: "All dependencies installed successfully.",
81
+ fail: "Dependency installation failed.",
82
+ info: "",
83
+ warn: "",
84
+ total: 4
85
+ },
86
+ {
87
+ step: 4,
88
+ start: "Ejecting project configuration...",
89
+ stop: "",
90
+ succeed: "Project ejected successfully.",
91
+ fail: "Project ejection failed.",
92
+ info: "",
93
+ warn: "",
94
+ total: 2
95
+ },
96
+ {
97
+ step: 5,
98
+ start: "Generating Artifact...",
99
+ stop: "",
100
+ succeed: "Build successful! APK/IPA generated.",
101
+ fail: "Build failed! Error generating APK/IPA.",
102
+ info: "",
103
+ warn: "",
104
+ total: 2,
105
+ },
106
+ ];
107
+
108
+
109
+ function calculateTotalSteps(process){
110
+ return process.reduce((sum, step) => sum + (step.total || 0), 0);
111
+ }
112
+
113
+ module.exports={
114
+ previewSteps,
115
+ androidBuildSteps,
116
+ calculateTotalSteps
117
+ }
@@ -0,0 +1,147 @@
1
+ const readline = require("readline");
2
+ const chalk = require("chalk");
3
+ const { ProgressBar, overallProgressBar } = require("./progress-bar");
4
+
5
+ class CustomSpinnerBar {
6
+ constructor(options = {}) {
7
+ if (!options.newInstance && CustomSpinnerBar.instance) {
8
+ return CustomSpinnerBar.instance;
9
+ }
10
+
11
+ if (!options.newInstance) {
12
+ CustomSpinnerBar.instance = this;
13
+ }
14
+
15
+ this.text = options.text || "Loading";
16
+ this.spinner = options.spinner || [
17
+ "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏",
18
+ ];
19
+ this.interval = options.interval || 80;
20
+ this.stream = process.stderr;
21
+ this.frameIndex = 0;
22
+ this.isSpinning = false;
23
+ this.spinnerInterval = null;
24
+
25
+ this.progressBar = new ProgressBar(options);
26
+ }
27
+
28
+ start(text) {
29
+ if (global.verbose) return;
30
+ if (text) this.text = text;
31
+ this.isSpinning = true;
32
+ this.frameIndex = 0;
33
+ this.resetProgressBar();
34
+ this.progressBar.start();
35
+ this.render();
36
+ this.spinnerInterval = setInterval(() => this.render(), this.interval);
37
+ return this;
38
+ }
39
+
40
+ stop() {
41
+ if (global.verbose) return this;
42
+ this.isSpinning = false;
43
+ clearInterval(this.spinnerInterval);
44
+ this.spinnerInterval = null;
45
+ readline.clearLine(this.stream, 0);
46
+ readline.cursorTo(this.stream, 0);
47
+ return this;
48
+ }
49
+
50
+ succeed(text) {
51
+ if (global?.verbose) return this;
52
+ this.stop();
53
+
54
+ this.progressBar.setProgress(this.progressBar.total);
55
+
56
+ let output = `${chalk.green("✔")} ${text || this.text}`;
57
+ output += " " + this.progressBar.render();
58
+
59
+ this.stream.write(`${output}\n`);
60
+ return this;
61
+ }
62
+
63
+ fail(text) {
64
+ if (global.verbose) return this;
65
+ this.stop();
66
+ let finalText = text || this.text;
67
+ if(global.logDirectory){
68
+ finalText += chalk.gray(" Check logs at: ") + chalk.cyan(global.logDirectory);
69
+ }
70
+ this.stream.write(`${chalk.red('✖')} ${chalk.bold.red(finalText)}\n`);
71
+ process.exit(1);
72
+ // return this;
73
+ }
74
+
75
+ info(text) {
76
+ if (global.verbose) return this;
77
+ this.stop();
78
+ this.stream.write(`${chalk.blue("ℹ")} ${text || this.text}\n`);
79
+ return this;
80
+ }
81
+
82
+ warn(text) {
83
+ if (global.verbose) return this;
84
+ this.stop();
85
+ this.stream.write(`${chalk.yellow("⚠")} ${text || this.text}\n`);
86
+ return this;
87
+ }
88
+
89
+ render() {
90
+ if (global.verbose) return;
91
+ readline.clearLine(this.stream, 0);
92
+ readline.cursorTo(this.stream, 0);
93
+
94
+ const frame = this.spinner[this.frameIndex] || '';
95
+ const progressBar = this.progressBar?.render() || '';
96
+ const overallProgress = overallProgressBar?.render() || '';
97
+
98
+ const output = `${chalk.cyan(frame)} ${this.text} ${progressBar} ${overallProgressBar.status() ?`| ${overallProgress}` : ''}`;
99
+ this.stream.write(output);
100
+
101
+ this.frameIndex = (this.frameIndex + 1) % this.spinner.length;
102
+ }
103
+
104
+ setText(text) {
105
+ this.text = text;
106
+ return this;
107
+ }
108
+
109
+ resetProgressBar(startValue = 0) {
110
+ this.progressBar.value = Math.min(Math.max(0, startValue), this.progressBar.total);
111
+ this.progressBar.startTime = Date.now();
112
+ return this;
113
+ }
114
+
115
+ setProgress(value) {
116
+ this.progressBar.setProgress(value);
117
+ overallProgressBar.setProgress(value);
118
+ return this;
119
+ }
120
+
121
+ incrementProgress(amount = 1) {
122
+ this.progressBar.incrementProgress(amount);
123
+ overallProgressBar.incrementProgress(amount);
124
+ return this;
125
+ }
126
+
127
+ setTotal(total) {
128
+ this.progressBar.setTotal(total);
129
+ return this;
130
+ }
131
+
132
+ enableProgressBar() {
133
+ this.progressBar.enable();
134
+ return this;
135
+ }
136
+
137
+ disableProgressBar() {
138
+ this.progressBar.disable();
139
+ return this;
140
+ }
141
+ }
142
+
143
+ // Exporting singleton instance and function for new instance
144
+ module.exports = {
145
+ spinnerBar: new CustomSpinnerBar(),
146
+ createNewSpinnerBar: (options) => new CustomSpinnerBar({ ...options, newInstance: true })
147
+ };
package/src/exec.js ADDED
@@ -0,0 +1,73 @@
1
+ const execa = require('execa');
2
+ const logger = require('./logger');
3
+ const loggerLabel = 'exec';
4
+
5
+ function isErrorWithoutWarning(v) {
6
+ const lowerV = v.toLowerCase();
7
+ return lowerV.includes("error") && (!lowerV.includes("warning") && !lowerV.includes("warn"));
8
+ }
9
+
10
+ class OutputPipe {
11
+ constructor(bufferSize, log, loggerLabel) {
12
+ this.output = '';
13
+ this.content = [];
14
+ this.bufferSize = bufferSize || 100;
15
+ this.logOutput = (log !== false);
16
+ this.loggerLabel = loggerLabel;
17
+ }
18
+ log(str, isErrorType) {
19
+ let reminder = '';
20
+ str.split('\n').forEach((v, i, splits) => {
21
+ if (i < splits.length - 1) {
22
+ v && (this.logOutput || isErrorType) && (isErrorType && isErrorWithoutWarning(v) ? logger.error({label: this.loggerLabel, message: v}) : logger.debug({label: this.loggerLabel, message: v}));
23
+ if (this.content.length > this.bufferSize) {
24
+ this.content.shift();
25
+ }
26
+ this.content.push(v);
27
+ } else {
28
+ reminder = v;
29
+ }
30
+ });
31
+ return reminder;
32
+ }
33
+ push(str, isErrorType) {
34
+ if (str) {
35
+ this.output = this.log(this.output + str, isErrorType) || '';
36
+ }
37
+ }
38
+ flush() {
39
+ this.log(this.output + '\n');
40
+ }
41
+ }
42
+
43
+ module.exports = {
44
+ 'exec': (cmd, args, options) => {
45
+ logger.info({
46
+ label: loggerLabel,
47
+ message: `
48
+ \x1b[1;34m ╔════════════════════════════════════╗
49
+ ║ Executing: ${cmd} ${(args && args.join(' '))}
50
+ ╚════════════════════════════════════╝\x1b[0m
51
+ `
52
+ });
53
+
54
+ const outputPipe = new OutputPipe(100, options && options.log, cmd.substr(cmd.lastIndexOf('/') + 1));
55
+ const spawn = execa(cmd, args, {...options, env:{...process.env, FORCE_COLOR:'1'}});
56
+ spawn.stdout.on('data', (data) => {
57
+ outputPipe.push(String.fromCharCode.apply(null, new Uint16Array(data)));
58
+ });
59
+ spawn.stderr.on('data', (data) => {
60
+ outputPipe.push(String.fromCharCode.apply(null, new Uint16Array(data)), true);
61
+ });
62
+ return new Promise((resolve, reject) => {
63
+ spawn.on('close', code => {
64
+ outputPipe.flush();
65
+ if (code == 0) {
66
+ resolve(outputPipe.content);
67
+ } else {
68
+ reject(code);
69
+ }
70
+ });
71
+ });
72
+ }
73
+ };