neonctl 2.8.0 → 2.9.1
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/analytics.js +5 -0
- package/commands/auth.js +92 -40
- package/commands/auth.test.js +134 -4
- package/commands/index.js +0 -2
- package/index.js +0 -2
- package/package.json +2 -3
- package/commands/bootstrap/authjs-secret.js +0 -6
- package/commands/bootstrap/index.js +0 -842
- package/commands/bootstrap/index.test.js +0 -93
- package/commands/bootstrap/is-folder-empty.js +0 -56
- package/commands/bootstrap/validate-pkg.js +0 -15
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { expect, describe } from 'vitest';
|
|
2
|
-
import { fork } from 'node:child_process';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { log } from '../../log';
|
|
5
|
-
import { test } from '../../test_utils/fixtures';
|
|
6
|
-
describe('bootstrap/create-app', () => {
|
|
7
|
-
// We create an app without a schema and without deploying it, as
|
|
8
|
-
// a very simple check that the CLI works. Eventually, we need
|
|
9
|
-
// to have a much more complete test suite that actually verifies
|
|
10
|
-
// that launching all different app combinations works.
|
|
11
|
-
test.skip('very simple CLI interaction test', async ({ runMockServer }) => {
|
|
12
|
-
const server = await runMockServer('main');
|
|
13
|
-
// Most of this forking code is copied from `test_cli_command.ts`.
|
|
14
|
-
const cp = fork(join(process.cwd(), './dist/index.js'), [
|
|
15
|
-
'--api-host',
|
|
16
|
-
`http://localhost:${server.address().port}`,
|
|
17
|
-
'--output',
|
|
18
|
-
'yaml',
|
|
19
|
-
'--api-key',
|
|
20
|
-
'test-key',
|
|
21
|
-
'--no-analytics',
|
|
22
|
-
'create-app',
|
|
23
|
-
], {
|
|
24
|
-
stdio: 'pipe',
|
|
25
|
-
env: {
|
|
26
|
-
PATH: `mocks/bin:${process.env.PATH}`,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
process.on('SIGINT', () => {
|
|
30
|
-
cp.kill();
|
|
31
|
-
});
|
|
32
|
-
let neonProjectCreated = false;
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
cp.stdout?.on('data', (data) => {
|
|
35
|
-
const stdout = data.toString();
|
|
36
|
-
log.info(stdout);
|
|
37
|
-
// For some unknown, weird reason, when we send TAB clicks (\t),
|
|
38
|
-
// they only affect the next question. So, we send TAB below
|
|
39
|
-
// in order to affect the answer to the following prompt, not the
|
|
40
|
-
// current one.
|
|
41
|
-
if (stdout.includes('What is your project named')) {
|
|
42
|
-
cp.stdin?.write('my-app\n');
|
|
43
|
-
}
|
|
44
|
-
else if (stdout.includes('Which package manager would you like to use')) {
|
|
45
|
-
cp.stdin?.write('\n');
|
|
46
|
-
}
|
|
47
|
-
else if (stdout.includes('What framework would you like to use')) {
|
|
48
|
-
cp.stdin?.write('\n');
|
|
49
|
-
}
|
|
50
|
-
else if (stdout.includes('What ORM would you like to use')) {
|
|
51
|
-
cp.stdin?.write('\t'); // change auth.js
|
|
52
|
-
cp.stdin?.write('\n');
|
|
53
|
-
}
|
|
54
|
-
else if (stdout.includes('What authentication framework do you want to use')) {
|
|
55
|
-
cp.stdin?.write('\n');
|
|
56
|
-
}
|
|
57
|
-
else if (stdout.includes('What Neon project would you like to use')) {
|
|
58
|
-
neonProjectCreated = true;
|
|
59
|
-
cp.stdin?.write('\t'); // change deployment
|
|
60
|
-
cp.stdin?.write('\t');
|
|
61
|
-
cp.stdin?.write('\n');
|
|
62
|
-
}
|
|
63
|
-
else if (stdout.includes('Where would you like to deploy')) {
|
|
64
|
-
cp.stdin?.write('\n');
|
|
65
|
-
cp.stdin?.write('\n');
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
cp.stderr?.on('data', (data) => {
|
|
69
|
-
log.error(data.toString());
|
|
70
|
-
});
|
|
71
|
-
cp.on('error', (err) => {
|
|
72
|
-
throw err;
|
|
73
|
-
});
|
|
74
|
-
cp.on('close', (code) => {
|
|
75
|
-
// If we got to the point that a Neon project was successfully
|
|
76
|
-
// created, we consider the test run to be a success. We can't
|
|
77
|
-
// currently check that the template is properly generated, and that
|
|
78
|
-
// the project runs. We'll have to do that with containerization in
|
|
79
|
-
// the future, most likely.
|
|
80
|
-
if (neonProjectCreated) {
|
|
81
|
-
resolve();
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
expect(code).toBe(0);
|
|
85
|
-
resolve();
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}, 1000 * 60 * 5);
|
|
93
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Code copied from `create-next-app`.
|
|
2
|
-
import { lstatSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
// `isFolderEmpty` checks if a folder is empty and ready to onboard a Next.js package into it.
|
|
6
|
-
// It will actually log to stdout as part of its execution.
|
|
7
|
-
export function isFolderEmpty(root, name, writeStdout) {
|
|
8
|
-
const validFiles = new Set([
|
|
9
|
-
'.DS_Store',
|
|
10
|
-
'.git',
|
|
11
|
-
'.gitattributes',
|
|
12
|
-
'.gitignore',
|
|
13
|
-
'.gitlab-ci.yml',
|
|
14
|
-
'.hg',
|
|
15
|
-
'.hgcheck',
|
|
16
|
-
'.hgignore',
|
|
17
|
-
'.idea',
|
|
18
|
-
'.npmignore',
|
|
19
|
-
'.travis.yml',
|
|
20
|
-
'LICENSE',
|
|
21
|
-
'Thumbs.db',
|
|
22
|
-
'docs',
|
|
23
|
-
'mkdocs.yml',
|
|
24
|
-
'npm-debug.log',
|
|
25
|
-
'yarn-debug.log',
|
|
26
|
-
'yarn-error.log',
|
|
27
|
-
'yarnrc.yml',
|
|
28
|
-
'.yarn',
|
|
29
|
-
]);
|
|
30
|
-
const conflicts = readdirSync(root).filter((file) => !validFiles.has(file) &&
|
|
31
|
-
// Support IntelliJ IDEA-based editors
|
|
32
|
-
!file.endsWith('.iml'));
|
|
33
|
-
if (conflicts.length > 0) {
|
|
34
|
-
writeStdout(`The directory ${chalk.green(name)} contains files that could conflict:\n`);
|
|
35
|
-
writeStdout('');
|
|
36
|
-
for (const file of conflicts) {
|
|
37
|
-
try {
|
|
38
|
-
const stats = lstatSync(join(root, file));
|
|
39
|
-
if (stats.isDirectory()) {
|
|
40
|
-
writeStdout(` ${chalk.blue(file)}/\n`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
writeStdout(` ${file}\n`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
writeStdout(` ${file}\n`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
writeStdout('\n');
|
|
51
|
-
writeStdout('Either try using a new directory name, or remove the files listed above.\n');
|
|
52
|
-
writeStdout('\n');
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Code copied from `create-next-app`.
|
|
2
|
-
import validateProjectName from 'validate-npm-package-name';
|
|
3
|
-
export function validateNpmName(name) {
|
|
4
|
-
const nameValidation = validateProjectName(name);
|
|
5
|
-
if (nameValidation.validForNewPackages) {
|
|
6
|
-
return { valid: true };
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
valid: false,
|
|
10
|
-
problems: [
|
|
11
|
-
...(nameValidation.errors || []),
|
|
12
|
-
...(nameValidation.warnings || []),
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
}
|