safelaunch 1.0.9 → 1.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safelaunch",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Backend Reliability Infrastructure - catch what breaks production before it breaks",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/init.js CHANGED
@@ -54,4 +54,54 @@ async function init() {
54
54
  const projectType = detectProjectType(cwd);
55
55
  const extensions = ['.js', '.ts', '.jsx', '.tsx', '.vue', '.svelte'];
56
56
  let pattern;
57
- let typeLabel;
57
+ let typeLabel;
58
+
59
+ if (projectType === 'vite') {
60
+ pattern = /import\.meta\.env\.([A-Z_][A-Z0-9_]*)/g;
61
+ typeLabel = 'Vite';
62
+ } else if (projectType === 'cra') {
63
+ pattern = /process\.env\.(REACT_APP_[A-Z0-9_]*)/g;
64
+ typeLabel = 'Create React App';
65
+ } else if (projectType === 'next') {
66
+ pattern = /process\.env\.([A-Z_][A-Z0-9_]*)/g;
67
+ typeLabel = 'Next.js';
68
+ } else {
69
+ pattern = /process\.env\.([A-Z_][A-Z0-9_]*)/g;
70
+ typeLabel = 'Node.js';
71
+ }
72
+
73
+ console.log('detected project type: ' + typeLabel + '\n');
74
+ const found = scanFiles(cwd, extensions, pattern);
75
+
76
+ if (found.size === 0) {
77
+ console.log('no environment variables found in your project.\n');
78
+ await track('safelaunch_init_run', { project_type: projectType, vars_found: 0 });
79
+ await shutdown();
80
+ return;
81
+ }
82
+
83
+ const variables = {};
84
+ for (const key of [...found].sort()) {
85
+ variables[key] = { required: true, description: '' };
86
+ }
87
+
88
+ const manifest = {
89
+ version: '1',
90
+ projectType: projectType,
91
+ runtime: { node: process.version.replace('v', '').split('.')[0] },
92
+ variables
93
+ };
94
+
95
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
96
+
97
+ console.log('found ' + found.size + ' environment variables:\n');
98
+ for (const key of [...found].sort()) {
99
+ console.log(' ' + key);
100
+ }
101
+ console.log('\ncreated env.manifest.json\n');
102
+
103
+ await track('safelaunch_init_run', { project_type: projectType, vars_found: found.size });
104
+ await shutdown();
105
+ }
106
+
107
+ init();
package/src/telemetry.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { PostHog } = require('posthog-node');
2
2
 
3
- const client = new PostHog('phx_T3nHhNj4dVFDHRHbDaqoXTmqeic8kM6fa3nyjXpTanqxcVD', {
3
+ const client = new PostHog('phc_WFm3O5H7wkZK2Ne3kyy5QgUXJR8y86SQbszSwk3BUn0', {
4
4
  host: 'https://us.i.posthog.com'
5
5
  });
6
6