@augment-vir/node 30.0.0 → 30.0.2
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/README.md +7 -10
- package/dist/augments/docker.d.ts +49 -2
- package/dist/augments/docker.js +48 -2
- package/dist/augments/fs/download.d.ts +11 -0
- package/dist/augments/{download.js → fs/download.js} +7 -0
- package/dist/augments/fs/json.d.ts +42 -0
- package/dist/augments/fs/json.js +34 -0
- package/dist/augments/fs/read-dir.d.ts +11 -3
- package/dist/augments/fs/read-dir.js +11 -3
- package/dist/augments/fs/read-file.d.ts +8 -0
- package/dist/augments/fs/read-file.js +8 -0
- package/dist/augments/fs/symlink.d.ts +7 -0
- package/dist/augments/fs/symlink.js +7 -0
- package/dist/augments/fs/write.d.ts +4 -0
- package/dist/augments/fs/write.js +4 -0
- package/dist/augments/npm/query-workspace.d.ts +14 -0
- package/dist/augments/npm/query-workspace.js +8 -1
- package/dist/augments/npm/read-package-json.d.ts +9 -0
- package/dist/augments/npm/read-package-json.js +9 -0
- package/dist/augments/os/operating-system.d.ts +33 -0
- package/dist/augments/os/operating-system.js +35 -0
- package/dist/augments/path/ancestor.d.ts +19 -0
- package/dist/augments/path/ancestor.js +28 -0
- package/dist/augments/path/os-path.d.ts +19 -3
- package/dist/augments/path/os-path.js +19 -3
- package/dist/augments/path/root.d.ts +7 -0
- package/dist/augments/path/root.js +7 -0
- package/dist/augments/prisma.d.ts +137 -1
- package/dist/augments/prisma.js +135 -1
- package/dist/augments/terminal/question.d.ts +50 -0
- package/dist/augments/{console → terminal}/question.js +23 -2
- package/dist/augments/{shell.d.ts → terminal/shell.d.ts} +87 -4
- package/dist/augments/{shell.js → terminal/shell.js} +63 -3
- package/dist/docker/containers/container-info.d.ts +35 -6
- package/dist/docker/containers/container-info.js +1 -7
- package/dist/docker/containers/container-status.d.ts +15 -0
- package/dist/docker/containers/container-status.js +16 -1
- package/dist/docker/containers/copy-to-container.d.ts +7 -0
- package/dist/docker/containers/copy-to-container.js +1 -1
- package/dist/docker/containers/docker-command-inputs.d.ts +54 -0
- package/dist/docker/containers/docker-command-inputs.js +9 -0
- package/dist/docker/containers/kill-container.js +1 -1
- package/dist/docker/containers/run-command.d.ts +8 -2
- package/dist/docker/containers/run-command.js +1 -2
- package/dist/docker/containers/run-container.d.ts +7 -0
- package/dist/docker/containers/run-container.js +1 -1
- package/dist/docker/docker-image.js +4 -2
- package/dist/docker/docker-startup.js +1 -2
- package/dist/docker/run-docker-test.mock.d.ts +2 -0
- package/dist/docker/run-docker-test.mock.js +16 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/prisma/disable-ci-env.mock.d.ts +2 -0
- package/dist/prisma/disable-ci-env.mock.js +81 -0
- package/dist/prisma/model-data.d.ts +73 -0
- package/dist/prisma/model-data.js +70 -0
- package/dist/prisma/prisma-client.d.ts +0 -4
- package/dist/prisma/prisma-client.js +0 -4
- package/dist/prisma/prisma-errors.d.ts +25 -0
- package/dist/prisma/prisma-errors.js +25 -0
- package/dist/prisma/prisma-migrations.d.ts +12 -6
- package/dist/prisma/prisma-migrations.js +1 -7
- package/dist/prisma/run-prisma-command.d.ts +1 -1
- package/dist/prisma/run-prisma-command.js +1 -1
- package/package.json +23 -13
- package/dist/augments/console/question.d.ts +0 -14
- package/dist/augments/download.d.ts +0 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// cspell:disable
|
|
2
|
+
import { arrayToObject } from '@augment-vir/common';
|
|
3
|
+
/**
|
|
4
|
+
* These are all the env flags that Prisma reads for determining if it's being executed within a CI
|
|
5
|
+
* environment. This list was retrieved from
|
|
6
|
+
* https://github.com/prisma/prisma/blob/075d31287c90b757fd9bd8d9b36032e6349fa671/packages/internals/src/utils/isCi.ts.
|
|
7
|
+
*/
|
|
8
|
+
const prismaCiFlags = [
|
|
9
|
+
'CI',
|
|
10
|
+
'CONTINUOUS_INTEGRATION',
|
|
11
|
+
'BUILD_NUMBER',
|
|
12
|
+
'RUN_ID',
|
|
13
|
+
'AGOLA_GIT_REF',
|
|
14
|
+
'AC_APPCIRCLE',
|
|
15
|
+
'APPVEYOR',
|
|
16
|
+
'CODEBUILD',
|
|
17
|
+
'TF_BUILD',
|
|
18
|
+
'bamboo_planKey',
|
|
19
|
+
'BITBUCKET_COMMIT',
|
|
20
|
+
'BITRISE_IO',
|
|
21
|
+
'BUDDY_WORKSPACE_ID',
|
|
22
|
+
'BUILDKITE',
|
|
23
|
+
'CIRCLECI',
|
|
24
|
+
'CIRRUS_CI',
|
|
25
|
+
'CF_BUILD_ID',
|
|
26
|
+
'CM_BUILD_ID',
|
|
27
|
+
'CI_NAME',
|
|
28
|
+
'DRONE',
|
|
29
|
+
'DSARI',
|
|
30
|
+
'EARTHLY_CI',
|
|
31
|
+
'EAS_BUILD',
|
|
32
|
+
'GERRIT_PROJECT',
|
|
33
|
+
'GITEA_ACTIONS',
|
|
34
|
+
'GITHUB_ACTIONS',
|
|
35
|
+
'GITLAB_CI',
|
|
36
|
+
'GOCD',
|
|
37
|
+
'BUILDER_OUTPUT',
|
|
38
|
+
'HARNESS_BUILD_ID',
|
|
39
|
+
'JENKINS_URL',
|
|
40
|
+
'BUILD_ID',
|
|
41
|
+
'LAYERCI',
|
|
42
|
+
'MAGNUM',
|
|
43
|
+
'NETLIFY',
|
|
44
|
+
'NEVERCODE',
|
|
45
|
+
'PROW_JOB_ID',
|
|
46
|
+
'RELEASE_BUILD_ID',
|
|
47
|
+
'RENDER',
|
|
48
|
+
'SAILCI',
|
|
49
|
+
'HUDSON',
|
|
50
|
+
'JENKINS_URL',
|
|
51
|
+
'BUILD_ID',
|
|
52
|
+
'SCREWDRIVER',
|
|
53
|
+
'SEMAPHORE',
|
|
54
|
+
'SOURCEHUT',
|
|
55
|
+
'STRIDER',
|
|
56
|
+
'TASK_ID',
|
|
57
|
+
'RUN_ID',
|
|
58
|
+
'TEAMCITY_VERSION',
|
|
59
|
+
'TRAVIS',
|
|
60
|
+
'VELA',
|
|
61
|
+
'NOW_BUILDER',
|
|
62
|
+
'APPCENTER_BUILD_ID',
|
|
63
|
+
'CI_XCODE_PROJECT',
|
|
64
|
+
'XCS',
|
|
65
|
+
];
|
|
66
|
+
export function testWithNonCiEnv(callback) {
|
|
67
|
+
return async () => {
|
|
68
|
+
const usedKeys = prismaCiFlags.filter((ciFlag) => ciFlag in process.env);
|
|
69
|
+
/** For already non-CI environments. */
|
|
70
|
+
/* node:coverage ignore next 6 */
|
|
71
|
+
const originalEnvValues = arrayToObject(usedKeys, (key) => {
|
|
72
|
+
return {
|
|
73
|
+
key,
|
|
74
|
+
value: process.env[key],
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
usedKeys.forEach((key) => delete process.env[key]);
|
|
78
|
+
await callback();
|
|
79
|
+
usedKeys.forEach((key) => (process.env[key] = originalEnvValues[key]));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BasePrismaClient, PrismaAllModelsCreate, type PartialWithUndefined, type PrismaAllBasicModels, type PrismaModelName } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* Params for {@link addData}. This is similar to {@link PrismaAllModelsCreate} but allows an array of
|
|
4
|
+
* {@link PrismaAllModelsCreate} for sequential data creation.
|
|
5
|
+
*
|
|
6
|
+
* @category Prisma : Node
|
|
7
|
+
* @category Package : @augment-vir/node
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {PrismaAddModelData} from '@augment-vir/common';
|
|
12
|
+
* import type {PrismaClient} from '@prisma/client';
|
|
13
|
+
*
|
|
14
|
+
* const mockData: PrismaAddModelData<PrismaClient> = [
|
|
15
|
+
* {
|
|
16
|
+
* user: {
|
|
17
|
+
* mockUser1: {
|
|
18
|
+
* first_name: 'one',
|
|
19
|
+
* id: 123,
|
|
20
|
+
* // etc.
|
|
21
|
+
* },
|
|
22
|
+
* mockUser2: {
|
|
23
|
+
* first_name: 'two',
|
|
24
|
+
* id: 124,
|
|
25
|
+
* authRole: 'user',
|
|
26
|
+
* // etc.
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* {
|
|
31
|
+
* region: [
|
|
32
|
+
* {
|
|
33
|
+
* id: 1,
|
|
34
|
+
* name: 'North America',
|
|
35
|
+
* // etc.
|
|
36
|
+
* },
|
|
37
|
+
* {
|
|
38
|
+
* id: 2,
|
|
39
|
+
* name: 'Europe',
|
|
40
|
+
* // etc.
|
|
41
|
+
* },
|
|
42
|
+
* ],
|
|
43
|
+
* },
|
|
44
|
+
* ];
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
48
|
+
*/
|
|
49
|
+
export type PrismaAddDataData<PrismaClient extends BasePrismaClient> = Readonly<PrismaAllModelsCreate<PrismaClient>> | ReadonlyArray<Readonly<PrismaAllModelsCreate<PrismaClient>>>;
|
|
50
|
+
export declare function addData<const PrismaClient extends BasePrismaClient>(prismaClient: Readonly<PrismaClient>, data: PrismaAddDataData<PrismaClient>): Promise<void>;
|
|
51
|
+
export declare function getAllPrismaModelNames<const PrismaClient extends BasePrismaClient>(prismaClient: PrismaClient): PrismaModelName<PrismaClient>[];
|
|
52
|
+
/**
|
|
53
|
+
* Options for `prisma.client.dumpData`.
|
|
54
|
+
*
|
|
55
|
+
* @category Prisma : Node
|
|
56
|
+
* @category Package : @augment-vir/node
|
|
57
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
58
|
+
*/
|
|
59
|
+
export type PrismaDataDumpOptions = {
|
|
60
|
+
/**
|
|
61
|
+
* The max number of entries to load per model. Set to `0` to remove this limit altogether
|
|
62
|
+
* (which could be _very_ expensive for your database).
|
|
63
|
+
*
|
|
64
|
+
* @default 100
|
|
65
|
+
*/
|
|
66
|
+
limit: number;
|
|
67
|
+
/**
|
|
68
|
+
* Strings to omit from the dumped data. For testability, omitting date or UUID id fields is a
|
|
69
|
+
* common practice.
|
|
70
|
+
*/
|
|
71
|
+
omitFields: string[];
|
|
72
|
+
};
|
|
73
|
+
export declare function dumpData<const PrismaClient extends BasePrismaClient>(prismaClient: PrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>): Promise<PrismaAllBasicModels<PrismaClient>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { assert, check } from '@augment-vir/assert';
|
|
2
|
+
import { arrayToObject, awaitedForEach, ensureErrorAndPrependMessage, filterMap, getObjectTypedEntries, getObjectTypedValues, mergeDefinedProperties, omitObjectKeys, prismaModelCreateExclude, prismaModelCreateOmitId, } from '@augment-vir/common';
|
|
3
|
+
export async function addData(prismaClient, data) {
|
|
4
|
+
const dataArray = (check.isArray(data) ? data : [data]);
|
|
5
|
+
await awaitedForEach(dataArray, async (dataEntry) => {
|
|
6
|
+
await addModelDataObject(prismaClient, dataEntry);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
async function addModelDataObject(prismaClient, data) {
|
|
10
|
+
/** Add the mock data to the mock prisma client. */
|
|
11
|
+
await awaitedForEach(getObjectTypedEntries(data), async ([modelName, mockData,]) => {
|
|
12
|
+
/**
|
|
13
|
+
* This type is dumbed down to just `AnyObject[]` because the union of all possible
|
|
14
|
+
* model data is just way too big (and not helpful as the inputs to this function are
|
|
15
|
+
* already type guarded).
|
|
16
|
+
*/
|
|
17
|
+
const mockModelInstances = Array.isArray(mockData)
|
|
18
|
+
? mockData
|
|
19
|
+
: getObjectTypedValues(mockData);
|
|
20
|
+
const modelApi = prismaClient[modelName];
|
|
21
|
+
assert.isDefined(modelApi, `No PrismaClient API found for model '${modelName}'`);
|
|
22
|
+
try {
|
|
23
|
+
const allData = filterMap(mockModelInstances, (entry) => {
|
|
24
|
+
return entry;
|
|
25
|
+
}, (mapped, modelEntry) => !modelEntry[prismaModelCreateExclude]);
|
|
26
|
+
await awaitedForEach(allData, async (modelEntry) => {
|
|
27
|
+
if (modelEntry[prismaModelCreateOmitId]) {
|
|
28
|
+
modelEntry = omitObjectKeys(modelEntry, ['id']);
|
|
29
|
+
}
|
|
30
|
+
await modelApi.create({
|
|
31
|
+
data: modelEntry,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw ensureErrorAndPrependMessage(error, `Failed to create many '${modelName}' entries.\n\n${JSON.stringify(mockModelInstances, null, 4)}\n\n`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function getAllPrismaModelNames(prismaClient) {
|
|
41
|
+
return Object.keys(prismaClient)
|
|
42
|
+
.filter((key) => !key.startsWith('$') && !key.startsWith('_'))
|
|
43
|
+
.sort();
|
|
44
|
+
}
|
|
45
|
+
const defaultPrismaDumpDataOptions = {
|
|
46
|
+
limit: 100,
|
|
47
|
+
omitFields: [],
|
|
48
|
+
};
|
|
49
|
+
export async function dumpData(prismaClient, options = {}) {
|
|
50
|
+
const modelNames = getAllPrismaModelNames(prismaClient);
|
|
51
|
+
const finalOptions = mergeDefinedProperties(defaultPrismaDumpDataOptions, options);
|
|
52
|
+
const data = await arrayToObject(modelNames, async (modelName) => {
|
|
53
|
+
const entries = await prismaClient[modelName].findMany(finalOptions.limit > 0
|
|
54
|
+
? {
|
|
55
|
+
take: finalOptions.limit,
|
|
56
|
+
}
|
|
57
|
+
: {});
|
|
58
|
+
if (!entries.length) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const filteredEntries = finalOptions.omitFields.length
|
|
62
|
+
? entries.map((entry) => omitObjectKeys(entry, finalOptions.omitFields))
|
|
63
|
+
: entries;
|
|
64
|
+
return {
|
|
65
|
+
key: modelName,
|
|
66
|
+
value: filteredEntries,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the Prisma JS
|
|
3
|
-
* client). This will work even if the database doesn't exist yet.
|
|
4
|
-
*/
|
|
5
1
|
export declare function generatePrismaClient(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
6
2
|
export declare function isGeneratedPrismaClientCurrent({ jsClientOutputDir, schemaFilePath, }: {
|
|
7
3
|
schemaFilePath: string;
|
|
@@ -3,10 +3,6 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { runPrismaCommand } from './run-prisma-command.js';
|
|
6
|
-
/**
|
|
7
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the Prisma JS
|
|
8
|
-
* client). This will work even if the database doesn't exist yet.
|
|
9
|
-
*/
|
|
10
6
|
export async function generatePrismaClient(schemaFilePath, env = {}) {
|
|
11
7
|
await runPrismaCommand({ command: 'generate' }, schemaFilePath, env);
|
|
12
8
|
}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown by the Prisma API that indicates that something is wrong with the given Prisma
|
|
3
|
+
* schema. See the error message for more details.
|
|
4
|
+
*
|
|
5
|
+
* @category Prisma : Node : Util
|
|
6
|
+
* @category Package : @augment-vir/node
|
|
7
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
8
|
+
*/
|
|
1
9
|
export declare class PrismaSchemaError extends Error {
|
|
2
10
|
readonly name = "PrismaSchemaError";
|
|
3
11
|
constructor(message: string);
|
|
4
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
15
|
+
* a new migration is needed. You can do that by prompting user for a new migration name and passing
|
|
16
|
+
* it to `prisma.migration.create`.
|
|
17
|
+
*
|
|
18
|
+
* @category Prisma : Node : Util
|
|
19
|
+
* @category Package : @augment-vir/node
|
|
20
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
21
|
+
*/
|
|
5
22
|
export declare class PrismaMigrationNeededError extends Error {
|
|
6
23
|
readonly name = "PrismaMigrationNeededError";
|
|
7
24
|
constructor(schemaFilePath: string);
|
|
8
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
28
|
+
* the entire database needs to be reset. You can do that by calling `prisma.database.resetDev`.
|
|
29
|
+
*
|
|
30
|
+
* @category Prisma : Node : Util
|
|
31
|
+
* @category Package : @augment-vir/node
|
|
32
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
33
|
+
*/
|
|
9
34
|
export declare class PrismaResetNeededError extends Error {
|
|
10
35
|
readonly name = "PrismaResetNeededError";
|
|
11
36
|
constructor(schemaFilePath: string);
|
|
@@ -1,15 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown by the Prisma API that indicates that something is wrong with the given Prisma
|
|
3
|
+
* schema. See the error message for more details.
|
|
4
|
+
*
|
|
5
|
+
* @category Prisma : Node : Util
|
|
6
|
+
* @category Package : @augment-vir/node
|
|
7
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
8
|
+
*/
|
|
1
9
|
export class PrismaSchemaError extends Error {
|
|
2
10
|
name = 'PrismaSchemaError';
|
|
3
11
|
constructor(message) {
|
|
4
12
|
super(message);
|
|
5
13
|
}
|
|
6
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
17
|
+
* a new migration is needed. You can do that by prompting user for a new migration name and passing
|
|
18
|
+
* it to `prisma.migration.create`.
|
|
19
|
+
*
|
|
20
|
+
* @category Prisma : Node : Util
|
|
21
|
+
* @category Package : @augment-vir/node
|
|
22
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
23
|
+
*/
|
|
7
24
|
export class PrismaMigrationNeededError extends Error {
|
|
8
25
|
name = 'PrismaMigrationNeededError';
|
|
9
26
|
constructor(schemaFilePath) {
|
|
10
27
|
super(`A new Prisma migration is needed for '${schemaFilePath}'`);
|
|
11
28
|
}
|
|
12
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
32
|
+
* the entire database needs to be reset. You can do that by calling `prisma.database.resetDev`.
|
|
33
|
+
*
|
|
34
|
+
* @category Prisma : Node : Util
|
|
35
|
+
* @category Package : @augment-vir/node
|
|
36
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
37
|
+
*/
|
|
13
38
|
export class PrismaResetNeededError extends Error {
|
|
14
39
|
name = 'PrismaResetNeededError';
|
|
15
40
|
constructor(schemaFilePath) {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output of `prisma.migration.status`.
|
|
3
|
+
*
|
|
4
|
+
* @category Prisma : Node : Util
|
|
5
|
+
* @category Package : @augment-vir/node
|
|
6
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
7
|
+
*/
|
|
1
8
|
export type PrismaMigrationStatus = {
|
|
2
9
|
totalMigrations: number;
|
|
3
10
|
unappliedMigrations: string[];
|
|
4
11
|
};
|
|
5
12
|
export declare function applyPrismaMigrationsToProd(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs to input
|
|
8
|
-
* a name.
|
|
9
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and it needs
|
|
10
|
-
* to be reset.
|
|
11
|
-
*/
|
|
12
13
|
export declare function applyPrismaMigrationsToDev(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
13
14
|
export declare function getMigrationStatus(schemaFilePath: string, env?: Record<string, string>): Promise<PrismaMigrationStatus>;
|
|
14
15
|
export declare function createPrismaMigration({ migrationName, createOnly, }: {
|
|
15
16
|
migrationName: string;
|
|
17
|
+
/**
|
|
18
|
+
* Set this to `true` to create a new migration without applying it to the database.
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
16
22
|
createOnly?: boolean | undefined;
|
|
17
23
|
}, schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { log, safeMatch, toEnsuredNumber } from '@augment-vir/common';
|
|
3
3
|
import terminate from 'terminate';
|
|
4
|
-
import { runShellCommand } from '../augments/shell.js';
|
|
4
|
+
import { runShellCommand } from '../augments/terminal/shell.js';
|
|
5
5
|
import { PrismaMigrationNeededError, PrismaResetNeededError } from './prisma-errors.js';
|
|
6
6
|
import { runPrismaCommand, verifyOutput } from './run-prisma-command.js';
|
|
7
7
|
export async function applyPrismaMigrationsToProd(schemaFilePath, env = {}) {
|
|
@@ -12,12 +12,6 @@ var DbChangeRequired;
|
|
|
12
12
|
DbChangeRequired["MigrationNeeded"] = "migration-needed";
|
|
13
13
|
DbChangeRequired["ResetNeeded"] = "reset-needed";
|
|
14
14
|
})(DbChangeRequired || (DbChangeRequired = {}));
|
|
15
|
-
/**
|
|
16
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs to input
|
|
17
|
-
* a name.
|
|
18
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and it needs
|
|
19
|
-
* to be reset.
|
|
20
|
-
*/
|
|
21
15
|
export async function applyPrismaMigrationsToDev(schemaFilePath, env = {}) {
|
|
22
16
|
const command = [
|
|
23
17
|
'prisma',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { log } from '@augment-vir/common';
|
|
2
|
-
import { runShellCommand } from '../augments/shell.js';
|
|
2
|
+
import { runShellCommand } from '../augments/terminal/shell.js';
|
|
3
3
|
import { PrismaSchemaError } from './prisma-errors.js';
|
|
4
4
|
const prismaCommandsThatSupportNoHints = [
|
|
5
5
|
'generate',
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "30.0.
|
|
3
|
+
"version": "30.0.2",
|
|
4
|
+
"description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"augment",
|
|
7
|
+
"helper",
|
|
8
|
+
"util",
|
|
9
|
+
"node",
|
|
10
|
+
"browser",
|
|
11
|
+
"backend",
|
|
12
|
+
"frontend",
|
|
13
|
+
"vir",
|
|
14
|
+
"augment-vir"
|
|
15
|
+
],
|
|
4
16
|
"homepage": "https://github.com/electrovir/augment-vir",
|
|
5
17
|
"bugs": {
|
|
6
18
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -20,34 +32,32 @@
|
|
|
20
32
|
"types": "dist/index.d.ts",
|
|
21
33
|
"scripts": {
|
|
22
34
|
"compile": "virmator compile",
|
|
23
|
-
"docs": "virmator docs",
|
|
24
35
|
"test": "virmator --no-deps test node --test-concurrency 1",
|
|
25
36
|
"test:coverage": "virmator test node coverage --test-concurrency 1",
|
|
26
|
-
"test:docs": "virmator docs check",
|
|
27
37
|
"test:update": "npm test"
|
|
28
38
|
},
|
|
29
39
|
"dependencies": {
|
|
30
|
-
"@augment-vir/assert": "^30.0.
|
|
31
|
-
"@augment-vir/common": "^30.0.
|
|
40
|
+
"@augment-vir/assert": "^30.0.2",
|
|
41
|
+
"@augment-vir/common": "^30.0.2",
|
|
32
42
|
"@date-vir/duration": "^6.0.0",
|
|
33
43
|
"ansi-styles": "^6.2.1",
|
|
34
44
|
"terminate": "^2.8.0",
|
|
35
|
-
"type-fest": "^4.
|
|
45
|
+
"type-fest": "^4.26.1",
|
|
36
46
|
"typed-event-target": "^3.4.0"
|
|
37
47
|
},
|
|
38
48
|
"devDependencies": {
|
|
39
|
-
"@augment-vir/test": "^30.0.
|
|
40
|
-
"@prisma/client": "^5.19.
|
|
41
|
-
"@types/node": "^22.5.
|
|
49
|
+
"@augment-vir/test": "^30.0.2",
|
|
50
|
+
"@prisma/client": "^5.19.1",
|
|
51
|
+
"@types/node": "^22.5.4",
|
|
42
52
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
43
|
-
"@web/test-runner": "^0.
|
|
53
|
+
"@web/test-runner": "^0.19.0",
|
|
44
54
|
"@web/test-runner-commands": "^0.9.0",
|
|
45
55
|
"@web/test-runner-playwright": "^0.11.0",
|
|
46
|
-
"@web/test-runner-visual-regression": "^0.
|
|
56
|
+
"@web/test-runner-visual-regression": "^0.10.0",
|
|
47
57
|
"c8": "^10.1.2",
|
|
48
|
-
"concurrently": "^
|
|
58
|
+
"concurrently": "^9.0.0",
|
|
49
59
|
"istanbul-smart-text-reporter": "^1.1.4",
|
|
50
|
-
"prisma": "^5.19.
|
|
60
|
+
"prisma": "^5.19.1"
|
|
51
61
|
},
|
|
52
62
|
"engines": {
|
|
53
63
|
"node": ">=22"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type AnyDuration } from '@date-vir/duration';
|
|
2
|
-
/** Can't test requiring user input. */
|
|
3
|
-
export type AskQuestionOptions = {
|
|
4
|
-
timeout: AnyDuration;
|
|
5
|
-
hideUserInput: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function askQuestion(questionToAsk: string, { hideUserInput, timeout, }?: Partial<AskQuestionOptions>): Promise<string>;
|
|
8
|
-
export type QuestionUntilConditionMetConfig = {
|
|
9
|
-
questionToAsk: string;
|
|
10
|
-
conditionCallback: (response: string) => boolean | Promise<boolean>;
|
|
11
|
-
invalidInputMessage: string;
|
|
12
|
-
tryCountMax?: number;
|
|
13
|
-
} & Partial<AskQuestionOptions>;
|
|
14
|
-
export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, ...options }: QuestionUntilConditionMetConfig): Promise<string>;
|