This commit is contained in:
Nathan Bierema 2023-01-05 12:04:55 -05:00
parent fa25234d36
commit 2cc9122a24
12 changed files with 37 additions and 29 deletions

View File

@ -16,6 +16,7 @@
"index.js",
"defaultDbOptions.json"
],
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
@ -52,7 +53,7 @@
"getport": "^0.1.0",
"graphql": "^16.6.0",
"knex": "^2.3.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"minimist": "^1.2.7",
"morgan": "^1.10.0",
"open": "^8.4.0",
@ -71,7 +72,7 @@
"@types/cross-spawn": "^6.0.2",
"@types/express": "^4.17.15",
"@types/jest": "^29.2.4",
"@types/lodash": "^4.14.191",
"@types/lodash-es": "^4.17.6",
"@types/minimist": "^1.2.2",
"@types/morgan": "^1.9.3",
"@types/node": "^18.11.17",

View File

@ -1,5 +1,5 @@
import fs from 'fs';
import { Store } from '../store';
import type { Store } from '../store.js';
export const schema = fs
.readFileSync(require.resolve('./schema_def.graphql'))

View File

@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import semver from 'semver';
import { Options } from '../options';
import type { Options } from '../options.js';
const name = '@redux-devtools/cli';
const startFlag = '/* ' + name + ' start */';

View File

@ -1,7 +1,7 @@
import open from 'open';
import path from 'path';
import spawn from 'cross-spawn';
import { Options } from '../options';
import type { Options } from '../options.js';
export default async function openApp(app: true | string, options: Options) {
if (app === true || app === 'electron') {

View File

@ -3,10 +3,10 @@ import fs from 'fs';
import path from 'path';
import parseArgs from 'minimist';
import chalk from 'chalk';
import * as injectServer from './injectServer';
import getOptions from '../options';
import server from '../index';
import openApp from './openApp';
import * as injectServer from './injectServer.js';
import getOptions from '../options.js';
import server from '../index.js';
import openApp from './openApp.js';
const argv = parseArgs(process.argv.slice(2));

View File

@ -1,23 +1,23 @@
import path from 'path';
import knexModule, { Knex } from 'knex';
import { Knex, knex } from 'knex';
import { AGServer } from 'socketcluster-server';
export default function connector(options: AGServer.AGServerOptions) {
const dbOptions = options.dbOptions as Knex.Config;
dbOptions.useNullAsDefault = true;
if (!(dbOptions as any).migrate) {
return knexModule(dbOptions);
return knex(dbOptions);
}
dbOptions.migrations = { directory: path.resolve(__dirname, 'migrations') };
dbOptions.seeds = { directory: path.resolve(__dirname, 'seeds') };
const knex = knexModule(dbOptions);
const knexInstance = knex(dbOptions);
/* eslint-disable no-console */
knex.migrate
knexInstance.migrate
.latest({ loadExtensions: ['.js'] })
.then(function () {
return knex.seed.run({ loadExtensions: ['.js'] });
return knexInstance.seed.run({ loadExtensions: ['.js'] });
})
.then(function () {
console.log(' \x1b[0;32m[Done]\x1b[0m Migrations are finished\n');
@ -27,5 +27,5 @@ export default function connector(options: AGServer.AGServerOptions) {
});
/* eslint-enable no-console */
return knex;
return knexInstance;
}

View File

@ -2,9 +2,9 @@ import express from 'express';
import http from 'http';
import getPort from 'getport';
import socketClusterServer from 'socketcluster-server';
import getOptions, { Options } from './options';
import routes from './routes';
import createStore from './store';
import getOptions, { Options } from './options.js';
import routes from './routes.js';
import createStore from './store.js';
// var LOG_LEVEL_NONE = 0;
const LOG_LEVEL_ERROR = 1;

View File

@ -1,6 +1,6 @@
import { ApolloServer } from 'apollo-server-express';
import { schema, resolvers } from '../api/schema';
import { Store } from '../store';
import { schema, resolvers } from '../api/schema.js';
import type { Store } from '../store.js';
export default function (store: Store) {
return new ApolloServer({

View File

@ -7,8 +7,8 @@ import bodyParser from 'body-parser';
import cors from 'cors';
import { AGServer } from 'socketcluster-server';
import { ApolloServer } from 'apollo-server-express';
import { AddData, ReportBaseFields, Store } from './store';
import { resolvers, schema } from './api/schema';
import type { AddData, ReportBaseFields, Store } from './store.js';
import { resolvers, schema } from './api/schema.js';
const app = express.Router();

View File

@ -1,8 +1,8 @@
import { v4 as uuidV4 } from 'uuid';
import pick from 'lodash/pick';
import { pick } from 'lodash-es';
import { AGServer } from 'socketcluster-server';
import { Knex } from 'knex';
import connector from './db/connector';
import connector from './db/connector.js';
const reports = 'remotedev_reports';
// var payloads = 'remotedev_payloads';

View File

@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "dist"
},
"include": ["src"]

View File

@ -928,7 +928,7 @@ importers:
'@types/cross-spawn': ^6.0.2
'@types/express': ^4.17.15
'@types/jest': ^29.2.4
'@types/lodash': ^4.14.191
'@types/lodash-es': ^4.17.6
'@types/minimist': ^1.2.2
'@types/morgan': ^1.9.3
'@types/node': ^18.11.17
@ -955,7 +955,7 @@ importers:
graphql: ^16.6.0
jest: ^29.3.1
knex: ^2.3.0
lodash: ^4.17.21
lodash-es: ^4.17.21
minimist: ^1.2.7
morgan: ^1.10.0
ncp: ^2.0.0
@ -986,7 +986,7 @@ importers:
getport: 0.1.0
graphql: 16.6.0
knex: 2.3.0_sqlite3@5.1.4
lodash: 4.17.21
lodash-es: 4.17.21
minimist: 1.2.7
morgan: 1.10.0
open: 8.4.0
@ -1004,7 +1004,7 @@ importers:
'@types/cross-spawn': 6.0.2
'@types/express': 4.17.15
'@types/jest': 29.2.4
'@types/lodash': 4.14.191
'@types/lodash-es': 4.17.6
'@types/minimist': 1.2.2
'@types/morgan': 1.9.3
'@types/node': 18.11.17
@ -8532,6 +8532,12 @@ packages:
dependencies:
'@types/node': 16.18.10
/@types/lodash-es/4.17.6:
resolution: {integrity: sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==}
dependencies:
'@types/lodash': 4.14.191
dev: true
/@types/lodash.curry/4.1.7:
resolution: {integrity: sha512-R+IkSvh7CI8klh7FkQuTAiAR+aPFqYrNEjw/hMxjCSO7TsAqBAxpR99PxxJN1lgE6YuvpHEoktqbh6V5VLzxZA==}
dependencies: