@underpostnet/underpost 2.96.1 → 2.97.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.
package/src/index.js CHANGED
@@ -36,7 +36,7 @@ class Underpost {
36
36
  * @type {String}
37
37
  * @memberof Underpost
38
38
  */
39
- static version = 'v2.96.1';
39
+ static version = 'v2.97.0';
40
40
  /**
41
41
  * Repository cli API
42
42
  * @static
package/src/server/dns.js CHANGED
@@ -36,7 +36,9 @@ class Dns {
36
36
  static async getPublicIp() {
37
37
  return await new Promise(async (resolve) => {
38
38
  try {
39
- return axios.get('https://api.ipify.org').then((response) => resolve(response.data));
39
+ return axios
40
+ .get(process.env.HTTP_PLAIN_IP_URL ? process.env.HTTP_PLAIN_IP_URL : 'https://api.ipify.org')
41
+ .then((response) => resolve(response.data));
40
42
  } catch (error) {
41
43
  logger.error('Error fetching public IP:', { error: error.message, stack: error.stack });
42
44
  return resolve(null);
@@ -403,6 +405,7 @@ class Dns {
403
405
  * @property {boolean} [options.banEgressClear=false] - Clear all banned egress IPs.
404
406
  * @property {boolean} [options.banBothAdd=false] - Ban IPs from both ingress and egress.
405
407
  * @property {boolean} [options.banBothRemove=false] - Unban IPs from both ingress and egress.
408
+ * @property {boolean} [options.dhcp=false] - Get local DHCP IP instead of public IP.
406
409
  * @property {boolean} [options.copy=false] - Copy the public IP to clipboard.
407
410
  * @return {Promise<string|void>} The public IP if no ban/unban action is taken.
408
411
  */
@@ -420,6 +423,7 @@ class Dns {
420
423
  banBothAdd: false,
421
424
  banBothRemove: false,
422
425
  copy: false,
426
+ dhcp: false,
423
427
  },
424
428
  ) {
425
429
  const ipList = ips
@@ -468,7 +472,9 @@ class Dns {
468
472
  });
469
473
  }
470
474
 
471
- const ip = await Dns.getPublicIp();
475
+ let ip;
476
+ if (options.dhcp) ip = Dns.getLocalIPv4Address();
477
+ else ip = await Dns.getPublicIp();
472
478
  if (options.copy) return pbcopy(ip);
473
479
  console.log(ip);
474
480
  return ip;
@@ -117,20 +117,27 @@ class UnderpostStartUp {
117
117
  * @param {Object} options - Options for the deployment.
118
118
  * @param {boolean} options.build - Whether to build the deployment.
119
119
  * @param {boolean} options.run - Whether to run the deployment.
120
+ * @param {boolean} options.underpostQuicklyInstall - Whether to use underpost quickly install.
120
121
  */
121
- async callback(deployId = 'dd-default', env = 'development', options = { build: false, run: false }) {
122
+ async callback(
123
+ deployId = 'dd-default',
124
+ env = 'development',
125
+ options = { build: false, run: false, underpostQuicklyInstall: false },
126
+ ) {
122
127
  UnderpostRootEnv.API.set('container-status', `${deployId}-${env}-build-deployment`);
123
- if (options.build === true) await UnderpostStartUp.API.build(deployId, env);
128
+ if (options.build === true) await UnderpostStartUp.API.build(deployId, env, options);
124
129
  UnderpostRootEnv.API.set('container-status', `${deployId}-${env}-initializing-deployment`);
125
- if (options.run === true) await UnderpostStartUp.API.run(deployId, env);
130
+ if (options.run === true) await UnderpostStartUp.API.run(deployId, env, options);
126
131
  },
127
132
  /**
128
133
  * Run itc-scripts and builds client bundle.
129
134
  * @param {string} deployId - The ID of the deployment.
130
135
  * @param {string} env - The environment of the deployment.
136
+ * @param {Object} options - Options for the build.
137
+ * @param {boolean} options.underpostQuicklyInstall - Whether to use underpost quickly install.
131
138
  * @memberof UnderpostStartUp
132
139
  */
133
- async build(deployId = 'dd-default', env = 'development') {
140
+ async build(deployId = 'dd-default', env = 'development', options = { underpostQuicklyInstall: false }) {
134
141
  const buildBasePath = `/home/dd`;
135
142
  const repoName = `engine-${deployId.split('-')[1]}`;
136
143
  shellExec(`cd ${buildBasePath} && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}`);
@@ -140,7 +147,7 @@ class UnderpostStartUp {
140
147
  shellExec(`cd ${buildBasePath}/engine && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}-private`);
141
148
  shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
142
149
  shellCd(`${buildBasePath}/engine`);
143
- shellExec(`npm install`);
150
+ shellExec(options?.underpostQuicklyInstall ? `underpost install` : `npm install`);
144
151
  shellExec(`node bin/deploy conf ${deployId} ${env}`);
145
152
  if (fs.existsSync('./engine-private/itc-scripts')) {
146
153
  const itcScripts = await fs.readdir('./engine-private/itc-scripts');
@@ -153,9 +160,10 @@ class UnderpostStartUp {
153
160
  * Runs a deployment.
154
161
  * @param {string} deployId - The ID of the deployment.
155
162
  * @param {string} env - The environment of the deployment.
163
+ * @param {Object} options - Options for the run.
156
164
  * @memberof UnderpostStartUp
157
165
  */
158
- async run(deployId = 'dd-default', env = 'development') {
166
+ async run(deployId = 'dd-default', env = 'development', options = {}) {
159
167
  const runCmd = env === 'production' ? 'run prod-img' : 'run dev-img';
160
168
  if (fs.existsSync(`./engine-private/replica`)) {
161
169
  const replicas = await fs.readdir(`./engine-private/replica`);