@wirechunk/cli 0.0.1 → 0.0.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.
@@ -0,0 +1,96 @@
1
+ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
+ import type * as Types from '#api';
3
+
4
+ export type CreateExtensionVersionMutationVariables = Types.Exact<{
5
+ input: Types.CreateExtensionVersionInput;
6
+ }>;
7
+
8
+ export type CreateExtensionVersionMutation = {
9
+ createExtensionVersion:
10
+ | { __typename: 'AuthorizationError'; message: string }
11
+ | {
12
+ __typename: 'CreateExtensionVersionSuccessResult';
13
+ signedUrl: string;
14
+ extensionVersion: { __typename: 'ExtensionVersion'; id: string };
15
+ }
16
+ | { __typename: 'GenericInternalError'; message: string }
17
+ | { __typename: 'GenericUserError'; message: string };
18
+ };
19
+
20
+ export const CreateExtensionVersionDocument = {
21
+ kind: 'Document',
22
+ definitions: [
23
+ {
24
+ kind: 'OperationDefinition',
25
+ operation: 'mutation',
26
+ name: { kind: 'Name', value: 'CreateExtensionVersion' },
27
+ variableDefinitions: [
28
+ {
29
+ kind: 'VariableDefinition',
30
+ variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
31
+ type: {
32
+ kind: 'NonNullType',
33
+ type: {
34
+ kind: 'NamedType',
35
+ name: { kind: 'Name', value: 'CreateExtensionVersionInput' },
36
+ },
37
+ },
38
+ },
39
+ ],
40
+ selectionSet: {
41
+ kind: 'SelectionSet',
42
+ selections: [
43
+ {
44
+ kind: 'Field',
45
+ name: { kind: 'Name', value: 'createExtensionVersion' },
46
+ arguments: [
47
+ {
48
+ kind: 'Argument',
49
+ name: { kind: 'Name', value: 'input' },
50
+ value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
51
+ },
52
+ ],
53
+ selectionSet: {
54
+ kind: 'SelectionSet',
55
+ selections: [
56
+ { kind: 'Field', name: { kind: 'Name', value: '__typename' } },
57
+ {
58
+ kind: 'InlineFragment',
59
+ typeCondition: {
60
+ kind: 'NamedType',
61
+ name: { kind: 'Name', value: 'CreateExtensionVersionSuccessResult' },
62
+ },
63
+ selectionSet: {
64
+ kind: 'SelectionSet',
65
+ selections: [
66
+ {
67
+ kind: 'Field',
68
+ name: { kind: 'Name', value: 'extensionVersion' },
69
+ selectionSet: {
70
+ kind: 'SelectionSet',
71
+ selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
72
+ },
73
+ },
74
+ { kind: 'Field', name: { kind: 'Name', value: 'signedUrl' } },
75
+ ],
76
+ },
77
+ },
78
+ {
79
+ kind: 'InlineFragment',
80
+ typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Error' } },
81
+ selectionSet: {
82
+ kind: 'SelectionSet',
83
+ selections: [{ kind: 'Field', name: { kind: 'Name', value: 'message' } }],
84
+ },
85
+ },
86
+ ],
87
+ },
88
+ },
89
+ ],
90
+ },
91
+ },
92
+ ],
93
+ } as unknown as DocumentNode<
94
+ CreateExtensionVersionMutation,
95
+ CreateExtensionVersionMutationVariables
96
+ >;
@@ -0,0 +1,14 @@
1
+ mutation CreateExtensionVersion($input: CreateExtensionVersionInput!) {
2
+ createExtensionVersion(input: $input) {
3
+ __typename
4
+ ... on CreateExtensionVersionSuccessResult {
5
+ extensionVersion {
6
+ id
7
+ }
8
+ signedUrl
9
+ }
10
+ ... on Error {
11
+ message
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,23 @@
1
+ import type { GraphQLClient } from 'graphql-request';
2
+ import type {
3
+ CreateExtensionVersionMutation,
4
+ CreateExtensionVersionMutationVariables,
5
+ } from './mutations/create-extension-version.generated.ts';
6
+ import { CreateExtensionVersionDocument } from './mutations/create-extension-version.generated.ts';
7
+
8
+ export const createExtensionVersion = ({
9
+ client,
10
+ variables,
11
+ sessionAuthToken,
12
+ }: {
13
+ client: GraphQLClient;
14
+ variables: CreateExtensionVersionMutationVariables;
15
+ sessionAuthToken: string;
16
+ }): Promise<CreateExtensionVersionMutation> =>
17
+ client.request({
18
+ document: CreateExtensionVersionDocument,
19
+ variables,
20
+ requestHeaders: {
21
+ Authorization: `Bearer ${sessionAuthToken}`,
22
+ },
23
+ });
package/src/main.ts CHANGED
@@ -7,7 +7,7 @@ import { bootstrap } from './commands/bootstrap.ts';
7
7
  import { createExtensionVersion } from './commands/create-extension-version.ts';
8
8
  import { createUser } from './commands/create-user.ts';
9
9
  import { editAdmin } from './commands/edit-admin.ts';
10
- import { dbConnectInfo } from './commands/ext-dev/db-connect-info.ts';
10
+ import { getDbUrl } from './commands/ext-dev/get-db-url.ts';
11
11
  import { initDb } from './commands/ext-dev/init-db.ts';
12
12
  import type { Env } from './env.ts';
13
13
  import { parseEnv } from './env.ts';
@@ -18,7 +18,7 @@ const program = new Command()
18
18
  .option('--verbose', 'output debug logging')
19
19
  .option(
20
20
  '--env-mode <mode>',
21
- 'the mode to use for finding .env files to load environment variables, such as "test" to load .env, .env.test, .env.local, and .env.test.local',
21
+ 'the mode to use for finding .env files to load environment variables, such as "test" to load .env, .env.test, .env.local, and .env.test.local; also for finding config files to include when creating an extension or extension version, such as config.production.json',
22
22
  ).description(`The official Wirechunk CLI
23
23
 
24
24
  By default, environment variables are loaded from the .env file in the current working directory,
@@ -65,6 +65,10 @@ program
65
65
  'the ID of the extension, can be set with an EXTENSION_ID environment variable instead',
66
66
  )
67
67
  .requiredOption('--version-name <string>', 'the name of the version')
68
+ .option(
69
+ '--config-file <string>',
70
+ 'the path to a file to use when creating the extension version, containing environment-style key-value pairs',
71
+ )
68
72
  .action(withOptionsAndEnv(createExtensionVersion));
69
73
 
70
74
  program
@@ -94,15 +98,15 @@ program
94
98
  const extDev = program.command('ext-dev').description('extension development commands');
95
99
 
96
100
  extDev
97
- .command('db-connect-info')
101
+ .command('get-db-url')
98
102
  .description(
99
- 'write the connection info for the extension database to a .local.env or .local.<env-mode>.env file',
103
+ 'write the connection info for the extension database to a .env.local or .env.<env-mode>.local file',
100
104
  )
101
105
  .option(
102
106
  '--extension-id <string>',
103
107
  'the ID of the extension, can be set with an EXTENSION_ID environment variable instead',
104
108
  )
105
- .action(withOptionsAndEnv(dbConnectInfo));
109
+ .action(withOptionsAndEnv(getDbUrl));
106
110
 
107
111
  extDev
108
112
  .command('init-db')
@@ -1,10 +1,10 @@
1
1
  import { cleanSmallId } from '@wirechunk/lib/clean-small-id.ts';
2
- import { Permission } from '@wirechunk/lib/graphql-api-enums.ts';
2
+ import { PermissionName } from '@wirechunk/lib/graphql-api-enums.ts';
3
3
  import type { CommonQueryMethods } from 'slonik';
4
4
  import { sql } from 'slonik';
5
5
  import { voidSelectSchema } from '../util.ts';
6
6
 
7
- export const allPermissions = Object.values(Permission);
7
+ export const allPermissions = Object.values(PermissionName);
8
8
 
9
9
  export const revokeAllUserPlatformPermissions = async (
10
10
  {
package/tsconfig.json CHANGED
@@ -18,6 +18,9 @@
18
18
  "noUncheckedIndexedAccess": true,
19
19
  "noUnusedLocals": true,
20
20
  "skipLibCheck": false,
21
- "noEmit": true
21
+ "noEmit": true,
22
+ "paths": {
23
+ "#api": ["./src/core-api/api.ts"]
24
+ }
22
25
  }
23
26
  }