securenow 5.3.2 → 5.3.3

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 (3) hide show
  1. package/cli/apps.js +58 -0
  2. package/cli.js +1 -1
  3. package/package.json +1 -1
package/cli/apps.js CHANGED
@@ -56,8 +56,11 @@ async function create(args, flags) {
56
56
  if (flags.hosts) {
57
57
  body.hosts = flags.hosts.split(',').map(h => h.trim());
58
58
  }
59
+
59
60
  if (flags.instance) {
60
61
  body.instanceId = flags.instance;
62
+ } else if (process.stdin.isTTY) {
63
+ body.instanceId = await pickInstance();
61
64
  }
62
65
 
63
66
  const s = ui.spinner(`Creating application "${name}"`);
@@ -91,6 +94,61 @@ async function create(args, flags) {
91
94
  }
92
95
  }
93
96
 
97
+ async function pickInstance() {
98
+ const s = ui.spinner('Loading instances');
99
+ let instances = [];
100
+ try {
101
+ const data = await api.get('/instances');
102
+ instances = data.instances || [];
103
+ s.stop('Instances loaded');
104
+ } catch {
105
+ s.stop('Could not load instances');
106
+ return null;
107
+ }
108
+
109
+ const FREE_TRIAL_LABEL = `${ui.c.green('Free Trial')} ${ui.c.dim('— SecureNow managed instance (no setup needed)')}`;
110
+
111
+ const choices = [{ label: FREE_TRIAL_LABEL, value: null }];
112
+
113
+ for (const inst of instances) {
114
+ const status = inst.status === 'active' ? ui.c.green('●') : ui.c.red('●');
115
+ const apps = inst.linkedApps ? ui.c.dim(` (${inst.linkedApps} app${inst.linkedApps !== 1 ? 's' : ''})`) : '';
116
+ choices.push({
117
+ label: `${status} ${inst.name}${apps} ${ui.c.dim(`[${inst._id}]`)}`,
118
+ value: inst._id,
119
+ });
120
+ }
121
+
122
+ const appUrl = config.getAppUrl();
123
+ choices.push({
124
+ label: `${ui.c.cyan('+')} Create a new instance ${ui.c.dim('(opens browser)')}`,
125
+ value: '__new__',
126
+ });
127
+
128
+ const selected = await ui.select('Which instance should this app use?', choices);
129
+
130
+ if (selected === '__new__') {
131
+ const url = `${appUrl}/dashboard/settings/instances`;
132
+ ui.info(`Opening ${ui.c.underline(url)}`);
133
+ openBrowser(url);
134
+ ui.info('Create your instance in the browser, then run this command again.');
135
+ process.exit(0);
136
+ }
137
+
138
+ return selected;
139
+ }
140
+
141
+ function openBrowser(url) {
142
+ const { execSync } = require('child_process');
143
+ try {
144
+ if (process.platform === 'darwin') execSync(`open "${url}"`);
145
+ else if (process.platform === 'win32') execSync(`start "" "${url}"`);
146
+ else execSync(`xdg-open "${url}"`);
147
+ } catch {
148
+ ui.warn(`Could not open browser. Visit: ${url}`);
149
+ }
150
+ }
151
+
94
152
  async function info(args, flags) {
95
153
  requireAuth();
96
154
 
package/cli.js CHANGED
@@ -60,7 +60,7 @@ const COMMANDS = {
60
60
  usage: 'securenow apps <subcommand> [options]',
61
61
  sub: {
62
62
  list: { desc: 'List all applications', run: (a, f) => require('./cli/apps').list(a, f) },
63
- create: { desc: 'Create a new application', usage: 'securenow apps create <name> [--hosts host1,host2] [--instance <id>]', run: (a, f) => require('./cli/apps').create(a, f) },
63
+ create: { desc: 'Create a new application (interactive instance picker)', usage: 'securenow apps create <name> [--hosts host1,host2] [--instance <id>]', run: (a, f) => require('./cli/apps').create(a, f) },
64
64
  info: { desc: 'Show application details', usage: 'securenow apps info <id>', run: (a, f) => require('./cli/apps').info(a, f) },
65
65
  delete: { desc: 'Delete an application', usage: 'securenow apps delete <id> [--force]', run: (a, f) => require('./cli/apps').remove(a, f) },
66
66
  default: { desc: 'Set default application', usage: 'securenow apps default <key>', run: (a, f) => require('./cli/apps').setDefault(a, f) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "5.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "OpenTelemetry instrumentation for Node.js and Next.js - Send traces and logs to any OTLP-compatible backend",
5
5
  "type": "commonjs",
6
6
  "main": "register.js",