indraq_cli 2.5.0 → 2.7.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 (74) hide show
  1. package/README.md +84 -3
  2. package/cloud-api/.env.example +15 -15
  3. package/cloud-api/README.md +1 -1
  4. package/cloud-api/dist/index.js +78 -4
  5. package/cloud-api/dist/index.js.map +1 -0
  6. package/cloud-api/package.json +1 -1
  7. package/cloud-api/src/index.ts +54 -3
  8. package/dist/cli/help-content.d.ts.map +1 -1
  9. package/dist/cli/help-content.js +3 -2
  10. package/dist/cli/help-content.js.map +1 -1
  11. package/dist/modules/cloud/commands/cloud.command.d.ts.map +1 -1
  12. package/dist/modules/cloud/commands/cloud.command.js +124 -15
  13. package/dist/modules/cloud/commands/cloud.command.js.map +1 -1
  14. package/dist/modules/cloud/index.js +1 -1
  15. package/dist/modules/cloud/index.js.map +1 -1
  16. package/dist/modules/cloud/services/cloud-aws.service.d.ts +1 -1
  17. package/dist/modules/cloud/services/cloud-aws.service.d.ts.map +1 -1
  18. package/dist/modules/cloud/services/cloud-aws.service.js +2 -2
  19. package/dist/modules/cloud/services/cloud-aws.service.js.map +1 -1
  20. package/dist/modules/cloud/services/cloud-jenkins.service.d.ts +1 -1
  21. package/dist/modules/cloud/services/cloud-jenkins.service.d.ts.map +1 -1
  22. package/dist/modules/cloud/services/cloud-jenkins.service.js +2 -2
  23. package/dist/modules/cloud/services/cloud-jenkins.service.js.map +1 -1
  24. package/dist/modules/cloud/services/cloud-npm.service.d.ts +1 -1
  25. package/dist/modules/cloud/services/cloud-npm.service.d.ts.map +1 -1
  26. package/dist/modules/cloud/services/cloud-npm.service.js +2 -2
  27. package/dist/modules/cloud/services/cloud-npm.service.js.map +1 -1
  28. package/dist/modules/cloud/services/github-packages.service.d.ts +5 -0
  29. package/dist/modules/cloud/services/github-packages.service.d.ts.map +1 -0
  30. package/dist/modules/cloud/services/github-packages.service.js +38 -0
  31. package/dist/modules/cloud/services/github-packages.service.js.map +1 -0
  32. package/dist/modules/cloud/services/project-cleanup.service.d.ts +24 -0
  33. package/dist/modules/cloud/services/project-cleanup.service.d.ts.map +1 -0
  34. package/dist/modules/cloud/services/project-cleanup.service.js +143 -0
  35. package/dist/modules/cloud/services/project-cleanup.service.js.map +1 -0
  36. package/dist/modules/cloud/services/user-provider.service.d.ts +1 -1
  37. package/dist/modules/cloud/services/user-provider.service.d.ts.map +1 -1
  38. package/dist/modules/cloud/services/user-provider.service.js +3 -3
  39. package/dist/modules/cloud/services/user-provider.service.js.map +1 -1
  40. package/dist/modules/configure/configure.command.js +4 -2
  41. package/dist/modules/configure/configure.command.js.map +1 -1
  42. package/dist/modules/mobile/commands/ota.command.js +3 -3
  43. package/dist/modules/mobile/commands/ota.command.js.map +1 -1
  44. package/dist/modules/mobile/index.d.ts.map +1 -1
  45. package/dist/modules/mobile/index.js +8 -7
  46. package/dist/modules/mobile/index.js.map +1 -1
  47. package/dist/modules/mobile/services/mobile-project-directory.d.ts +8 -0
  48. package/dist/modules/mobile/services/mobile-project-directory.d.ts.map +1 -0
  49. package/dist/modules/mobile/services/mobile-project-directory.js +46 -0
  50. package/dist/modules/mobile/services/mobile-project-directory.js.map +1 -0
  51. package/dist/modules/mobile/services/ota-setup.service.d.ts.map +1 -1
  52. package/dist/modules/mobile/services/ota-setup.service.js +5 -3
  53. package/dist/modules/mobile/services/ota-setup.service.js.map +1 -1
  54. package/dist/modules/prebuild/commands/prebuild.command.d.ts +1 -0
  55. package/dist/modules/prebuild/commands/prebuild.command.d.ts.map +1 -1
  56. package/dist/modules/prebuild/commands/prebuild.command.js +92 -15
  57. package/dist/modules/prebuild/commands/prebuild.command.js.map +1 -1
  58. package/dist/modules/scaffold/commands/init.command.d.ts.map +1 -1
  59. package/dist/modules/scaffold/commands/init.command.js +32 -10
  60. package/dist/modules/scaffold/commands/init.command.js.map +1 -1
  61. package/dist/modules/scaffold/types.d.ts +3 -1
  62. package/dist/modules/scaffold/types.d.ts.map +1 -1
  63. package/dist/modules/setup/commands/setup.command.d.ts.map +1 -1
  64. package/dist/modules/setup/commands/setup.command.js +11 -3
  65. package/dist/modules/setup/commands/setup.command.js.map +1 -1
  66. package/dist/shared/process/run-npx.d.ts +4 -0
  67. package/dist/shared/process/run-npx.d.ts.map +1 -0
  68. package/dist/shared/process/run-npx.js +31 -0
  69. package/dist/shared/process/run-npx.js.map +1 -0
  70. package/docs/README_v2.6.0_DETAILED.md +1021 -0
  71. package/package.json +11 -4
  72. package/CHANGELOG_v2.5.0.md +0 -67
  73. package/RELEASE_CHECKS_v2.5.0.md +0 -93
  74. package/TEST_RESULTS_v2.5.0.txt +0 -46
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # IndraQ CLI v2.5.0
1
+ # IndraQ CLI v2.7.0
2
2
 
3
3
  IndraQ CLI helps our team set up, build and deploy web and mobile apps.
4
4
 
@@ -6,6 +6,58 @@ This guide uses simple steps. Start with the **Developer quick start**.
6
6
 
7
7
  ---
8
8
 
9
+ ## New in v2.7.0 (quick guide)
10
+
11
+ ### Backend + Mobile App
12
+
13
+ `indraq init` and `indraq project create` both offer **Backend + Mobile App**.
14
+ The generated project contains `backend/` and `mobile/` folders.
15
+
16
+ Run the same command from different folders:
17
+
18
+ ```powershell
19
+ cd C:\Projects\my-app\backend
20
+ indraq prebuild # Docker/GitHub Packages/Jenkins/Route53/NPM
21
+
22
+ cd ..\mobile
23
+ indraq prebuild # Mobile Jenkins + OTA only
24
+ indraq build mobile:dev # Development build
25
+ ```
26
+
27
+ From the project root, `indraq setup` walks through backend setup first, then mobile setup.
28
+ `indraq mobile prebuild --env immortility` always explicitly selects mobile setup.
29
+ Mobile build environments are separate from web deployment environments;
30
+ a Development mobile environment cannot run a Production build.
31
+
32
+ ### Reuse an existing provider resource
33
+
34
+ When setting up a component, choose **Link existing** instead of **Create/reconcile**.
35
+ You can link existing GitHub container packages, Jenkins deployment jobs, Route53 A records, and NPM proxy hosts.
36
+ The CLI confirms the resource exists in the selected scope and saves the association.
37
+ A linked resource is not silently overwritten; retain its existing configuration.
38
+ Route53 record discovery needs manager/admin access; this is intentional.
39
+
40
+ ### Safe permanent deletion
41
+
42
+ ```powershell
43
+ indraq project delete
44
+ ```
45
+
46
+ Select only the external resources you want removed; all default to **KEEP**.
47
+ The command now offers the exact provider scope when older projects have no scope link,
48
+ with MANAGE access required to delete external resources. For old GitHub Packages
49
+ scopes missing owner type, the CLI verifies the GitHub owner via GitHub's API
50
+ instead of guessing. Deleting a container package removes **all tags**.
51
+ Shared Jenkins mobile jobs, certificates, containers, and non-selected resources are not deleted.
52
+ If a deletion fails, the Cloud project is kept for retry.
53
+
54
+ **Upgrade:** Deploy Cloud API `1.3.0` before using CLI `2.7.0` deletion.
55
+ Use `npm install`, `npm run build`, `npm test`, and `npm publish --dry-run`
56
+ before publishing. Run the Cloud API build separately inside `cloud-api/`.
57
+
58
+ ---
59
+
60
+
9
61
  # Developer quick start — Web
10
62
 
11
63
  ## 1. Login once
@@ -118,7 +170,7 @@ latest
118
170
  or:
119
171
 
120
172
  ```text
121
- 1.2.0
173
+ 1.3.0
122
174
  ```
123
175
 
124
176
  IndraQ will:
@@ -674,4 +726,33 @@ npm publish
674
726
 
675
727
  ---
676
728
 
677
- **IndraQ Innovations — IndraQ CLI v2.5.0**
729
+ **IndraQ Innovations — IndraQ CLI v2.7.0**
730
+
731
+
732
+ ---
733
+
734
+ # What is new in v2.6.0
735
+
736
+ ## Backend + Mobile App
737
+
738
+ Choose **Backend + Mobile App** under `indraq init` or `indraq project create`.
739
+ The backend lives in `backend/` and uses normal Docker, GitHub Packages, Jenkins,
740
+ Route53, and NPM provisioning. The mobile app lives in `mobile/` and uses
741
+ Jenkins native builds and IndraQ OTA. `indraq setup` configures both once.
742
+
743
+ ## Project deletion cleanup
744
+
745
+ `indraq project delete` lists the actual resources linked to the project and
746
+ asks which to delete: Route53 A records, GitHub Packages container packages,
747
+ project-specific Jenkins jobs, and NPM proxy hosts. **Everything starts as KEEP.**
748
+ Shared resources and the shared mobile Jenkins pipeline are protected.
749
+ An external resource marked as linked requires extra approval to delete.
750
+ If any chosen provider deletion fails, the Cloud project stays available for retry.
751
+ Deleting GitHub Packages removes all tags and versions of the selected package.
752
+ AWS health checks, NPM certificates, running containers, and local source files
753
+ are not automatically deleted. `--yes` does not select any resources automatically.
754
+
755
+ ## Windows OTA signing fix
756
+
757
+ `expo-updates codesigning:generate` now uses a Windows-safe argument-preserving
758
+ `npx` launcher. Temporary private key material is cleaned up after errors too.
@@ -1,24 +1,24 @@
1
1
  PORT=4010
2
- DATABASE_URL=postgresql://harry:Staykool%401@192.168.10.101:23561/indraq_cloud
3
- JWT_SECRET=8f3c2a9d4e6b7f00112233445566778899aabbccddeeff001122334455667788
4
- MASTER_KEY=8f3c2a9d4e6b7f00112233445566778899aabbccddeeff001122334455667788
5
- BOOTSTRAP_ADMIN_EMAIL=harkaran@indraq.com
6
- BOOTSTRAP_ADMIN_PASSWORD=Saini@harkaran-1
2
+ DATABASE_URL=postgresql://indraq:change-me@127.0.0.1:5432/indraq_cloud
3
+ JWT_SECRET=replace-with-64-random-characters
4
+ MASTER_KEY=replace-with-64-hex-characters
5
+ BOOTSTRAP_ADMIN_EMAIL=admin@example.com
6
+ BOOTSTRAP_ADMIN_PASSWORD=change-this-immediately
7
7
 
8
8
  # Password-reset email (required for `indraq password reset`)
9
- SMTP_HOST=smtp.gmail.com
9
+ SMTP_HOST=smtp.example.com
10
10
  SMTP_PORT=587
11
11
  SMTP_SECURE=false
12
- SMTP_USER=info@indraq.com
13
- SMTP_PASS=wvmvbrwarpgraepy
14
- SMTP_FROM=IndraQ <info@indraq.com>
12
+ SMTP_USER=
13
+ SMTP_PASS=
14
+ SMTP_FROM=IndraQ <no-reply@example.com>
15
15
 
16
16
  # Mobile OTA / MinIO
17
- MINIO_ENDPOINT=api-minio.indraq.com
18
- MINIO_PORT=443
19
- MINIO_USE_SSL=true
20
- MINIO_ACCESS_KEY=Fp3uJObyDMciLxLJcZis
21
- MINIO_SECRET_KEY=EjGsHlglPsBtHNxNIofQq4A8jHlEMRwPwLTnnYg1-me
17
+ MINIO_ENDPOINT=127.0.0.1
18
+ MINIO_PORT=9000
19
+ MINIO_USE_SSL=false
20
+ MINIO_ACCESS_KEY=minioadmin
21
+ MINIO_SECRET_KEY=change-me
22
22
  MINIO_BUCKET=indraq-ota
23
23
  # Public Cloud API URL embedded into mobile builds. Keep this on the same cli.indraq.com backend.
24
- PUBLIC_API_URL=https://cli.indraq.com
24
+ PUBLIC_API_URL=https://cli.indraq.com
@@ -1,6 +1,6 @@
1
1
  # IndraQ Cloud API
2
2
 
3
- Control plane for IndraQ CLI v2.5.0 / Cloud API v1.1.0. The public CLI and OTA endpoint is `https://cli.indraq.com`.
3
+ Control plane for IndraQ CLI v2.6.0 / Cloud API v1.2.0. The public CLI and OTA endpoint is `https://cli.indraq.com`.
4
4
 
5
5
  ## Responsibilities
6
6
 
@@ -1228,6 +1228,47 @@ app.put('/projects/:id/deployment-topology', auth, async (req, res) => {
1228
1228
  await audit(req.auth.id, 'project.deployment.update', 'project', id, reason, { mode, environments: names });
1229
1229
  res.json({ ...result.rows[0], effective_access: 'write' });
1230
1230
  });
1231
+ // Inventory of exact project-owned provider resources before destructive project deletion.
1232
+ // The CLI uses this authoritative list, not guesses based on project names or DNS.
1233
+ app.get('/projects/:id/cleanup-inventory', ...allow('manager', 'admin'), async (req, res) => {
1234
+ const id = ensureUuid(routeParam(req.params.id), 'Project ID');
1235
+ if ((await projectAccessLevel(id, req.auth, true)) !== 'write') {
1236
+ res.status(403).json({ error: 'WRITE access to the project is required.' });
1237
+ return;
1238
+ }
1239
+ const rows = await pool.query(`SELECT id,environment,resource_type,provider,external_id,config
1240
+ FROM project_resources WHERE project_id=$1 ORDER BY provider,environment,resource_type`, [id]);
1241
+ const response = [];
1242
+ for (const row of rows.rows) {
1243
+ // A provider identifier alone is not enough when scopes may point to different accounts.
1244
+ // Treat same provider + resource identity anywhere in another project as shared; this
1245
+ // intentionally errs on the side of refusing destructive cleanup.
1246
+ const config = row.config || {};
1247
+ let shared = false;
1248
+ if (row.provider === 'ghcr' && typeof config.fullImage === 'string') {
1249
+ const result = await pool.query(`SELECT 1 FROM project_resources
1250
+ WHERE project_id<>$1 AND provider='ghcr' AND lower(config->>'fullImage')=lower($2) LIMIT 1`, [id, config.fullImage]);
1251
+ shared = !!result.rowCount;
1252
+ }
1253
+ else if (row.provider === 'aws' && config.zoneId && config.domain) {
1254
+ const result = await pool.query(`SELECT 1 FROM project_resources
1255
+ WHERE project_id<>$1 AND provider='aws' AND config->>'zoneId'=$2 AND lower(trim(trailing '.' from config->>'domain'))=lower(trim(trailing '.' from $3::text)) LIMIT 1`, [id, String(config.zoneId), String(config.domain)]);
1256
+ shared = !!result.rowCount;
1257
+ }
1258
+ else if (row.provider === 'npm' && config.proxyHostId) {
1259
+ const result = await pool.query(`SELECT 1 FROM project_resources
1260
+ WHERE project_id<>$1 AND provider='npm' AND config->>'proxyHostId'=$2 LIMIT 1`, [id, String(config.proxyHostId)]);
1261
+ shared = !!result.rowCount;
1262
+ }
1263
+ else if (String(row.provider).startsWith('jenkins-') && (config.jobName || row.external_id)) {
1264
+ const result = await pool.query(`SELECT 1 FROM project_resources
1265
+ WHERE project_id<>$1 AND provider=$2 AND coalesce(config->>'jobName',external_id)=$3 LIMIT 1`, [id, row.provider, String(config.jobName || row.external_id)]);
1266
+ shared = !!result.rowCount;
1267
+ }
1268
+ response.push({ ...row, shared_elsewhere: shared });
1269
+ }
1270
+ res.json(response);
1271
+ });
1231
1272
  app.delete('/projects/:id', ...allow('manager', 'admin'), async (req, res) => {
1232
1273
  const reason = requireReason(req, res);
1233
1274
  if (!reason)
@@ -1752,7 +1793,24 @@ app.post('/me/scopes/:provider/resolve', auth, async (req, res) => {
1752
1793
  }
1753
1794
  const projectId = req.body?.projectId ? ensureUuid(String(req.body.projectId), 'Project ID') : '';
1754
1795
  const environment = req.body?.environment ? environmentName(req.body.environment) : '';
1755
- if (projectId && !(await hasProjectAccess(projectId, req.auth))) {
1796
+ const mayCleanupArchived = req.body?.forCleanup === true && ['manager', 'admin'].includes(req.auth.role);
1797
+ const requestedScopeId = req.body?.scopeId ? ensureUuid(String(req.body.scopeId), 'Scope ID') : '';
1798
+ if (req.body?.forCleanup === true && !mayCleanupArchived) {
1799
+ res.status(403).json({ error: 'Provider deletion requires a manager or admin.' });
1800
+ return;
1801
+ }
1802
+ if (requestedScopeId && !mayCleanupArchived) {
1803
+ res.status(403).json({ error: 'Explicit scope selection is only permitted for authorized cleanup.' });
1804
+ return;
1805
+ }
1806
+ if (mayCleanupArchived && (!projectId || !environment)) {
1807
+ res.status(400).json({ error: 'Cleanup requires the project ID and associated environment.' });
1808
+ return;
1809
+ }
1810
+ const allowedProject = projectId && (mayCleanupArchived
1811
+ ? (await projectAccessLevel(projectId, req.auth, true)) === 'write'
1812
+ : await hasProjectAccess(projectId, req.auth));
1813
+ if (projectId && !allowedProject) {
1756
1814
  res.status(404).json({ error: 'Project not found or access denied' });
1757
1815
  return;
1758
1816
  }
@@ -1762,6 +1820,13 @@ app.post('/me/scopes/:provider/resolve', auth, async (req, res) => {
1762
1820
  if (linked.rowCount)
1763
1821
  scopeId = linked.rows[0].scope_id;
1764
1822
  }
1823
+ if (requestedScopeId) {
1824
+ if (scopeId && scopeId !== requestedScopeId) {
1825
+ res.status(409).json({ error: 'Selected scope conflicts with the existing project environment link.' });
1826
+ return;
1827
+ }
1828
+ scopeId = requestedScopeId;
1829
+ }
1765
1830
  if (!scopeId) {
1766
1831
  const preferred = await pool.query('SELECT scope_id FROM user_scope_defaults WHERE user_id=$1 AND provider=$2', [req.auth.id, provider]);
1767
1832
  if (preferred.rowCount)
@@ -1783,7 +1848,15 @@ app.post('/me/scopes/:provider/resolve', auth, async (req, res) => {
1783
1848
  res.status(404).json({ error: `No ${provider} scope is assigned to your account.` });
1784
1849
  return;
1785
1850
  }
1851
+ if (mayCleanupArchived && access !== 'manage' && access !== 'admin') {
1852
+ res.status(403).json({ error: 'Provider deletion requires MANAGE permission on the selected provider scope.' });
1853
+ return;
1854
+ }
1786
1855
  const row = (await pool.query('SELECT id,provider,name,description,company,config,encrypted_secret FROM provider_scopes WHERE id=$1 AND is_active=true', [scopeId])).rows[0];
1856
+ if (!row || row.provider !== provider) {
1857
+ res.status(400).json({ error: 'Selected scope is inactive or belongs to a different provider.' });
1858
+ return;
1859
+ }
1787
1860
  let secret = null;
1788
1861
  let credentialSource = 'scope-management';
1789
1862
  if (req.auth.role !== 'admin' && provider === 'aws') {
@@ -1818,7 +1891,8 @@ app.post('/me/scopes/:provider/resolve', auth, async (req, res) => {
1818
1891
  });
1819
1892
  app.get('/projects/:projectId/environment-scopes', auth, async (req, res) => {
1820
1893
  const projectId = ensureUuid(routeParam(req.params.projectId), 'Project ID');
1821
- if (!(await hasProjectAccess(projectId, req.auth))) {
1894
+ const hasAccess = await hasProjectAccess(projectId, req.auth) || (['manager', 'admin'].includes(req.auth.role) && (await projectAccessLevel(projectId, req.auth, true)) === 'write');
1895
+ if (!hasAccess) {
1822
1896
  res.status(404).json({ error: 'Project not found or access denied' });
1823
1897
  return;
1824
1898
  }
@@ -3057,8 +3131,8 @@ app.post('/projects/:projectId/mobile/register', auth, async (req, res) => {
3057
3131
  return;
3058
3132
  }
3059
3133
  const project = (await pool.query('SELECT id,kind FROM projects WHERE id=$1', [projectId])).rows[0];
3060
- if (!project || project.kind !== 'mobile') {
3061
- res.status(400).json({ error: 'OTA registration is available only for mobile projects.' });
3134
+ if (!project || !['mobile', 'backend-mobile'].includes(project.kind)) {
3135
+ res.status(400).json({ error: 'OTA registration requires a mobile or backend-mobile project.' });
3062
3136
  return;
3063
3137
  }
3064
3138
  const appName = textValue(req.body?.appName, 'App name', 100);