mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
475
backend/apis/nodejs/node_modules/knex/bin/cli.js
generated
vendored
Executable file
475
backend/apis/nodejs/node_modules/knex/bin/cli.js
generated
vendored
Executable file
@ -0,0 +1,475 @@
|
||||
#!/usr/bin/env node
|
||||
const rechoir = require('rechoir');
|
||||
const merge = require('lodash/merge');
|
||||
const interpret = require('interpret');
|
||||
const resolveFrom = require('resolve-from');
|
||||
const path = require('path');
|
||||
const tildify = require('tildify');
|
||||
const commander = require('commander');
|
||||
const color = require('colorette');
|
||||
const argv = require('getopts')(process.argv.slice(2));
|
||||
const cliPkg = require('../package');
|
||||
const {
|
||||
parseConfigObj,
|
||||
mkConfigObj,
|
||||
resolveEnvironmentConfig,
|
||||
exit,
|
||||
success,
|
||||
checkLocalModule,
|
||||
checkConfigurationOptions,
|
||||
getMigrationExtension,
|
||||
getSeedExtension,
|
||||
getStubPath,
|
||||
findUpModulePath,
|
||||
findUpConfig,
|
||||
} = require('./utils/cli-config-utils');
|
||||
const {
|
||||
existsSync,
|
||||
readFile,
|
||||
writeFile,
|
||||
} = require('../lib/migrations/util/fs');
|
||||
|
||||
const { listMigrations } = require('./utils/migrationsLister');
|
||||
|
||||
async function openKnexfile(configPath) {
|
||||
const importFile = require('../lib/migrations/util/import-file'); // require me late!
|
||||
let config = await importFile(configPath);
|
||||
if (config && config.default) {
|
||||
config = config.default;
|
||||
}
|
||||
if (typeof config === 'function') {
|
||||
config = await config();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
async function initKnex(env, opts, useDefaultClientIfNotSpecified) {
|
||||
checkLocalModule(env);
|
||||
if (process.cwd() !== env.cwd) {
|
||||
process.chdir(env.cwd);
|
||||
console.log(
|
||||
'Working directory changed to',
|
||||
color.magenta(tildify(env.cwd))
|
||||
);
|
||||
}
|
||||
|
||||
if (!useDefaultClientIfNotSpecified) {
|
||||
checkConfigurationOptions(env, opts);
|
||||
}
|
||||
|
||||
env.configuration = env.configPath
|
||||
? await openKnexfile(env.configPath)
|
||||
: mkConfigObj(opts);
|
||||
|
||||
const resolvedConfig = resolveEnvironmentConfig(
|
||||
opts,
|
||||
env.configuration,
|
||||
env.configPath
|
||||
);
|
||||
|
||||
const optionsConfig = parseConfigObj(opts);
|
||||
const config = merge(resolvedConfig, optionsConfig);
|
||||
|
||||
// Migrations directory gets defaulted if it is undefined.
|
||||
if (!env.configPath && !config.migrations.directory) {
|
||||
config.migrations.directory = null;
|
||||
}
|
||||
|
||||
// Client gets defaulted if undefined and it's allowed
|
||||
if (useDefaultClientIfNotSpecified && config.client === undefined) {
|
||||
config.client = 'sqlite3';
|
||||
}
|
||||
|
||||
const knex = require(env.modulePath);
|
||||
return knex(config);
|
||||
}
|
||||
|
||||
function invoke() {
|
||||
const filetypes = ['js', 'mjs', 'coffee', 'ts', 'eg', 'ls'];
|
||||
|
||||
const cwd = argv.knexfile
|
||||
? path.dirname(path.resolve(argv.knexfile))
|
||||
: process.cwd();
|
||||
|
||||
// TODO add knexpath here eventually
|
||||
const modulePath =
|
||||
resolveFrom.silent(cwd, 'knex') ||
|
||||
findUpModulePath(cwd, 'knex') ||
|
||||
process.env.KNEX_PATH;
|
||||
|
||||
const configPath =
|
||||
argv.knexfile && existsSync(argv.knexfile)
|
||||
? path.resolve(argv.knexfile)
|
||||
: findUpConfig(cwd, 'knexfile', filetypes);
|
||||
|
||||
if (configPath) {
|
||||
const autoloads = rechoir.prepare(
|
||||
interpret.jsVariants,
|
||||
configPath,
|
||||
cwd,
|
||||
true
|
||||
);
|
||||
if (autoloads instanceof Error) {
|
||||
// Only errors
|
||||
autoloads.failures.forEach(function (failed) {
|
||||
console.log(
|
||||
color.red('Failed to load external module'),
|
||||
color.magenta(failed.moduleName)
|
||||
);
|
||||
});
|
||||
} else if (Array.isArray(autoloads)) {
|
||||
const succeeded = autoloads[autoloads.length - 1];
|
||||
console.log(
|
||||
'Requiring external module',
|
||||
color.magenta(succeeded.moduleName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const env = {
|
||||
cwd,
|
||||
modulePath,
|
||||
configPath,
|
||||
configuration: null,
|
||||
};
|
||||
|
||||
let modulePackage = {};
|
||||
try {
|
||||
modulePackage = require(path.join(
|
||||
path.dirname(env.modulePath),
|
||||
'package.json'
|
||||
));
|
||||
} catch (e) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
const cliVersion = [
|
||||
color.blue('Knex CLI version:'),
|
||||
color.green(cliPkg.version),
|
||||
].join(' ');
|
||||
|
||||
const localVersion = [
|
||||
color.blue('Knex Local version:'),
|
||||
color.green(modulePackage.version || 'None'),
|
||||
].join(' ');
|
||||
|
||||
commander
|
||||
.version(`${cliVersion}\n${localVersion}`)
|
||||
.option('--debug', 'Run with debugging.')
|
||||
.option('--knexfile [path]', 'Specify the knexfile path.')
|
||||
.option('--knexpath [path]', 'Specify the path to knex instance.')
|
||||
.option('--cwd [path]', 'Specify the working directory.')
|
||||
.option('--client [name]', 'Set DB client.')
|
||||
.option('--connection [address]', 'Set DB connection.')
|
||||
.option('--migrations-directory [path]', 'Set migrations directory.')
|
||||
.option('--migrations-table-name [path]', 'Set migrations table name.')
|
||||
.option(
|
||||
'--env [name]',
|
||||
'environment, default: process.env.NODE_ENV || development'
|
||||
)
|
||||
.option('--esm', 'Enable ESM interop.')
|
||||
.option('--specific [path]', 'Specify one seed file to execute.')
|
||||
.option(
|
||||
'--timestamp-filename-prefix',
|
||||
'Enable a timestamp prefix on name of generated seed files.'
|
||||
);
|
||||
|
||||
commander
|
||||
.command('init')
|
||||
.description(' Create a fresh knexfile.')
|
||||
.option(
|
||||
`-x [${filetypes.join('|')}]`,
|
||||
'Specify the knexfile extension (default js)'
|
||||
)
|
||||
.action(() => {
|
||||
const type = (argv.x || 'js').toLowerCase();
|
||||
if (filetypes.indexOf(type) === -1) {
|
||||
exit(`Invalid filetype specified: ${type}`);
|
||||
}
|
||||
if (env.configuration) {
|
||||
exit(`Error: ${env.knexfile} already exists`);
|
||||
}
|
||||
checkLocalModule(env);
|
||||
const stubPath = `./knexfile.${type}`;
|
||||
readFile(
|
||||
path.dirname(env.modulePath) +
|
||||
'/lib/migrations/migrate/stub/knexfile-' +
|
||||
type +
|
||||
'.stub'
|
||||
)
|
||||
.then((code) => {
|
||||
return writeFile(stubPath, code);
|
||||
})
|
||||
.then(() => {
|
||||
success(color.green(`Created ${stubPath}`));
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:make <name>')
|
||||
.description(' Create a named migration file.')
|
||||
.option(
|
||||
`-x [${filetypes.join('|')}]`,
|
||||
'Specify the stub extension (default js)'
|
||||
)
|
||||
.option(
|
||||
`--stub [<relative/path/from/knexfile>|<name>]`,
|
||||
'Specify the migration stub to use. If using <name> the file must be located in config.migrations.directory'
|
||||
)
|
||||
.action(async (name) => {
|
||||
try {
|
||||
const opts = commander.opts();
|
||||
const instance = await initKnex(env, opts, true); // Skip config check, we don't really care about client when creating migrations
|
||||
const ext = getMigrationExtension(env, opts);
|
||||
const configOverrides = { extension: ext };
|
||||
|
||||
const stub = getStubPath('migrations', env, opts);
|
||||
if (stub) {
|
||||
configOverrides.stub = stub;
|
||||
}
|
||||
|
||||
instance.migrate
|
||||
.make(name, configOverrides)
|
||||
.then((name) => {
|
||||
success(color.green(`Created Migration: ${name}`));
|
||||
})
|
||||
.catch(exit);
|
||||
} catch (err) {
|
||||
exit(err);
|
||||
}
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:latest')
|
||||
.description(' Run all migrations that have not yet been run.')
|
||||
.option('--verbose', 'verbose')
|
||||
.action(async () => {
|
||||
try {
|
||||
const instance = await initKnex(env, commander.opts());
|
||||
const [batchNo, log] = await instance.migrate.latest();
|
||||
if (log.length === 0) {
|
||||
success(color.cyan('Already up to date'));
|
||||
}
|
||||
success(
|
||||
color.green(`Batch ${batchNo} run: ${log.length} migrations`) +
|
||||
(argv.verbose ? `\n${color.cyan(log.join('\n'))}` : '')
|
||||
);
|
||||
} catch (err) {
|
||||
exit(err);
|
||||
}
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:up [<name>]')
|
||||
.description(
|
||||
' Run the next or the specified migration that has not yet been run.'
|
||||
)
|
||||
.action((name) => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.migrate.up({ name }))
|
||||
.then(([batchNo, log]) => {
|
||||
if (log.length === 0) {
|
||||
success(color.cyan('Already up to date'));
|
||||
}
|
||||
|
||||
success(
|
||||
color.green(
|
||||
`Batch ${batchNo} ran the following migrations:\n${log.join(
|
||||
'\n'
|
||||
)}`
|
||||
)
|
||||
);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:rollback')
|
||||
.description(' Rollback the last batch of migrations performed.')
|
||||
.option('--all', 'rollback all completed migrations')
|
||||
.option('--verbose', 'verbose')
|
||||
.action((cmd) => {
|
||||
const { all } = cmd;
|
||||
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.migrate.rollback(null, all))
|
||||
.then(([batchNo, log]) => {
|
||||
if (log.length === 0) {
|
||||
success(color.cyan('Already at the base migration'));
|
||||
}
|
||||
success(
|
||||
color.green(
|
||||
`Batch ${batchNo} rolled back: ${log.length} migrations`
|
||||
) + (argv.verbose ? `\n${color.cyan(log.join('\n'))}` : '')
|
||||
);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:down [<name>]')
|
||||
.description(
|
||||
' Undo the last or the specified migration that was already run.'
|
||||
)
|
||||
.action((name) => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.migrate.down({ name }))
|
||||
.then(([batchNo, log]) => {
|
||||
if (log.length === 0) {
|
||||
success(color.cyan('Already at the base migration'));
|
||||
}
|
||||
success(
|
||||
color.green(
|
||||
`Batch ${batchNo} rolled back the following migrations:\n${log.join(
|
||||
'\n'
|
||||
)}`
|
||||
)
|
||||
);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:currentVersion')
|
||||
.description(' View the current version for the migration.')
|
||||
.action(() => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.migrate.currentVersion())
|
||||
.then((version) => {
|
||||
success(color.green('Current Version: ') + color.blue(version));
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:list')
|
||||
.alias('migrate:status')
|
||||
.description(' List all migrations files with status.')
|
||||
.action(() => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => {
|
||||
return instance.migrate.list();
|
||||
})
|
||||
.then(([completed, newMigrations]) => {
|
||||
listMigrations(completed, newMigrations);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('migrate:unlock')
|
||||
.description(' Forcibly unlocks the migrations lock table.')
|
||||
.action(() => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.migrate.forceFreeMigrationsLock())
|
||||
.then(() => {
|
||||
success(
|
||||
color.green(`Succesfully unlocked the migrations lock table`)
|
||||
);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander
|
||||
.command('seed:make <name>')
|
||||
.description(' Create a named seed file.')
|
||||
.option(
|
||||
`-x [${filetypes.join('|')}]`,
|
||||
'Specify the stub extension (default js)'
|
||||
)
|
||||
.option(
|
||||
`--stub [<relative/path/from/knexfile>|<name>]`,
|
||||
'Specify the seed stub to use. If using <name> the file must be located in config.seeds.directory'
|
||||
)
|
||||
.option(
|
||||
'--timestamp-filename-prefix',
|
||||
'Enable a timestamp prefix on name of generated seed files.',
|
||||
false
|
||||
)
|
||||
.action(async (name) => {
|
||||
try {
|
||||
const opts = commander.opts();
|
||||
const instance = await initKnex(env, opts, true); // Skip config check, we don't really care about client when creating seeds
|
||||
const ext = getSeedExtension(env, opts);
|
||||
const configOverrides = { extension: ext };
|
||||
const stub = getStubPath('seeds', env, opts);
|
||||
if (stub) {
|
||||
configOverrides.stub = stub;
|
||||
}
|
||||
|
||||
if (opts.timestampFilenamePrefix) {
|
||||
configOverrides.timestampFilenamePrefix =
|
||||
opts.timestampFilenamePrefix;
|
||||
}
|
||||
|
||||
instance.seed
|
||||
.make(name, configOverrides)
|
||||
.then((name) => {
|
||||
success(color.green(`Created seed file: ${name}`));
|
||||
})
|
||||
.catch(exit);
|
||||
} catch (err) {
|
||||
exit(err);
|
||||
}
|
||||
});
|
||||
|
||||
commander
|
||||
.command('seed:run')
|
||||
.description(' Run seed files.')
|
||||
.option('--verbose', 'verbose')
|
||||
.option('--specific', 'run specific seed file')
|
||||
.action(() => {
|
||||
initKnex(env, commander.opts())
|
||||
.then((instance) => instance.seed.run({ specific: argv.specific }))
|
||||
.then(([log]) => {
|
||||
if (log.length === 0) {
|
||||
success(color.cyan('No seed files exist'));
|
||||
}
|
||||
success(
|
||||
color.green(`Ran ${log.length} seed files`) +
|
||||
(argv.verbose ? `\n${color.cyan(log.join('\n'))}` : '')
|
||||
);
|
||||
})
|
||||
.catch(exit);
|
||||
});
|
||||
|
||||
commander.parse(process.argv);
|
||||
}
|
||||
|
||||
// FYI: The handling for the `--cwd` and `--knexfile` arguments is a bit strange,
|
||||
// but we decided to retain the behavior for backwards-compatibility. In
|
||||
// particular: if `--knexfile` is a relative path, then it will be resolved
|
||||
// relative to `--cwd` instead of the shell's CWD.
|
||||
//
|
||||
// So, the easiest way to replicate this behavior is to have the CLI change
|
||||
// its CWD to `--cwd` immediately before initializing everything else. This
|
||||
// ensures that path.resolve will then resolve the path to `--knexfile` correctly.
|
||||
if (argv.cwd) {
|
||||
process.chdir(argv.cwd);
|
||||
}
|
||||
// Initialize 'esm' before cli.launch
|
||||
if (argv.esm) {
|
||||
// enable esm interop via 'esm' module
|
||||
// eslint-disable-next-line no-global-assign
|
||||
require = require('esm')(module);
|
||||
// https://github.com/standard-things/esm/issues/868
|
||||
const ext = require.extensions['.js'];
|
||||
require.extensions['.js'] = (m, fileName) => {
|
||||
try {
|
||||
// default to the original extension
|
||||
// this fails if target file parent is of type='module'
|
||||
return ext(m, fileName);
|
||||
} catch (err) {
|
||||
if (err && err.code === 'ERR_REQUIRE_ESM') {
|
||||
return m._compile(
|
||||
require('fs').readFileSync(fileName, 'utf8'),
|
||||
fileName
|
||||
);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
invoke();
|
212
backend/apis/nodejs/node_modules/knex/bin/utils/cli-config-utils.js
generated
vendored
Normal file
212
backend/apis/nodejs/node_modules/knex/bin/utils/cli-config-utils.js
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
const { DEFAULT_EXT, DEFAULT_TABLE_NAME } = require('./constants');
|
||||
const { resolveClientNameWithAliases } = require('../../lib/util/helpers');
|
||||
const path = require('path');
|
||||
const escalade = require('escalade/sync');
|
||||
const tildify = require('tildify');
|
||||
const color = require('colorette');
|
||||
const argv = require('getopts')(process.argv.slice(2));
|
||||
|
||||
function parseConfigObj(opts) {
|
||||
const config = { migrations: {} };
|
||||
|
||||
if (opts.client) {
|
||||
config.client = opts.client;
|
||||
}
|
||||
|
||||
if (opts.connection) {
|
||||
config.connection = opts.connection;
|
||||
}
|
||||
|
||||
if (opts.migrationsDirectory) {
|
||||
config.migrations.directory = opts.migrationsDirectory;
|
||||
}
|
||||
|
||||
if (opts.migrationsTableName) {
|
||||
config.migrations.tableName = opts.migrationsTableName;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function mkConfigObj(opts) {
|
||||
const envName = opts.env || process.env.NODE_ENV || 'development';
|
||||
const resolvedClientName = resolveClientNameWithAliases(opts.client);
|
||||
const useNullAsDefault = resolvedClientName === 'sqlite3';
|
||||
const parsedConfig = parseConfigObj(opts);
|
||||
|
||||
return {
|
||||
ext: DEFAULT_EXT,
|
||||
[envName]: {
|
||||
...parsedConfig,
|
||||
useNullAsDefault,
|
||||
tableName: parsedConfig.tableName || DEFAULT_TABLE_NAME,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function resolveEnvironmentConfig(opts, allConfigs, configFilePath) {
|
||||
const environment = opts.env || process.env.NODE_ENV || 'development';
|
||||
const result = allConfigs[environment] || allConfigs;
|
||||
|
||||
if (allConfigs[environment]) {
|
||||
console.log('Using environment:', color.magenta(environment));
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
console.log(color.red('Warning: unable to read knexfile config'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (argv.debug !== undefined) {
|
||||
result.debug = argv.debug;
|
||||
}
|
||||
|
||||
// It is safe to assume that unless explicitly specified, we would want
|
||||
// migrations, seeds etc. to be generated with same extension
|
||||
if (configFilePath) {
|
||||
result.ext = result.ext || path.extname(configFilePath).replace('.', '');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function exit(text) {
|
||||
if (text instanceof Error) {
|
||||
if (text.message) {
|
||||
console.error(color.red(text.message));
|
||||
}
|
||||
console.error(
|
||||
color.red(`${text.detail ? `${text.detail}\n` : ''}${text.stack}`)
|
||||
);
|
||||
} else {
|
||||
console.error(color.red(text));
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function success(text) {
|
||||
console.log(text);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
function checkLocalModule(env) {
|
||||
if (!env.modulePath) {
|
||||
console.log(
|
||||
color.red('No local knex install found in:'),
|
||||
color.magenta(tildify(env.cwd))
|
||||
);
|
||||
exit('Try running: npm install knex');
|
||||
}
|
||||
}
|
||||
|
||||
function checkConfigurationOptions(env, opts) {
|
||||
if (!env.configPath && !opts.client) {
|
||||
throw new Error(
|
||||
`No configuration file found and no commandline connection parameters passed`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getMigrationExtension(env, opts) {
|
||||
const config = resolveEnvironmentConfig(
|
||||
opts,
|
||||
env.configuration,
|
||||
env.configPath
|
||||
);
|
||||
|
||||
let ext = DEFAULT_EXT;
|
||||
if (argv.x) {
|
||||
ext = argv.x;
|
||||
} else if (config.migrations && config.migrations.extension) {
|
||||
ext = config.migrations.extension;
|
||||
} else if (config.ext) {
|
||||
ext = config.ext;
|
||||
}
|
||||
return ext.toLowerCase();
|
||||
}
|
||||
|
||||
function getSeedExtension(env, opts) {
|
||||
const config = resolveEnvironmentConfig(
|
||||
opts,
|
||||
env.configuration,
|
||||
env.configPath
|
||||
);
|
||||
|
||||
let ext = DEFAULT_EXT;
|
||||
if (argv.x) {
|
||||
ext = argv.x;
|
||||
} else if (config.seeds && config.seeds.extension) {
|
||||
ext = config.seeds.extension;
|
||||
} else if (config.ext) {
|
||||
ext = config.ext;
|
||||
}
|
||||
return ext.toLowerCase();
|
||||
}
|
||||
|
||||
function getStubPath(configKey, env, opts) {
|
||||
const config = resolveEnvironmentConfig(opts, env.configuration);
|
||||
const stubDirectory = config[configKey] && config[configKey].directory;
|
||||
|
||||
const { stub } = argv;
|
||||
if (!stub) {
|
||||
return null;
|
||||
} else if (stub.includes('/')) {
|
||||
// relative path to stub
|
||||
return stub;
|
||||
}
|
||||
|
||||
// using stub <name> must have config[configKey].directory defined
|
||||
if (!stubDirectory) {
|
||||
console.log(color.red('Failed to load stub'), color.magenta(stub));
|
||||
exit(`config.${configKey}.directory in knexfile must be defined`);
|
||||
}
|
||||
|
||||
return path.join(stubDirectory, stub);
|
||||
}
|
||||
|
||||
function findUpModulePath(cwd, packageName) {
|
||||
const modulePackagePath = escalade(cwd, (dir, names) => {
|
||||
if (names.includes('package.json')) {
|
||||
return 'package.json';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
try {
|
||||
const modulePackage = require(modulePackagePath);
|
||||
if (modulePackage.name === packageName) {
|
||||
return path.join(
|
||||
path.dirname(modulePackagePath),
|
||||
modulePackage.main || 'index.js'
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
|
||||
function findUpConfig(cwd, name, extensions) {
|
||||
return escalade(cwd, (dir, names) => {
|
||||
for (const ext of extensions) {
|
||||
const filename = `${name}.${ext}`;
|
||||
if (names.includes(filename)) {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseConfigObj,
|
||||
mkConfigObj,
|
||||
resolveEnvironmentConfig,
|
||||
exit,
|
||||
success,
|
||||
checkLocalModule,
|
||||
checkConfigurationOptions,
|
||||
getSeedExtension,
|
||||
getMigrationExtension,
|
||||
getStubPath,
|
||||
findUpModulePath,
|
||||
findUpConfig,
|
||||
};
|
7
backend/apis/nodejs/node_modules/knex/bin/utils/constants.js
generated
vendored
Normal file
7
backend/apis/nodejs/node_modules/knex/bin/utils/constants.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
const DEFAULT_EXT = 'js';
|
||||
const DEFAULT_TABLE_NAME = 'knex_migrations';
|
||||
|
||||
module.exports = {
|
||||
DEFAULT_EXT,
|
||||
DEFAULT_TABLE_NAME,
|
||||
};
|
37
backend/apis/nodejs/node_modules/knex/bin/utils/migrationsLister.js
generated
vendored
Normal file
37
backend/apis/nodejs/node_modules/knex/bin/utils/migrationsLister.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
const color = require('colorette');
|
||||
|
||||
const { success } = require('./cli-config-utils');
|
||||
|
||||
function listMigrations(completed, newMigrations) {
|
||||
let message = '';
|
||||
|
||||
if (completed.length === 0) {
|
||||
message += color.red('No Completed Migration files Found.\n');
|
||||
} else {
|
||||
message = color.green(
|
||||
`Found ${completed.length} Completed Migration file/files.\n`
|
||||
);
|
||||
|
||||
for (let i = 0; i < completed.length; i++) {
|
||||
const file = completed[i];
|
||||
message += color.cyan(`${file.name}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
if (newMigrations.length === 0) {
|
||||
message += color.red('No Pending Migration files Found.\n');
|
||||
} else {
|
||||
message += color.green(
|
||||
`Found ${newMigrations.length} Pending Migration file/files.\n`
|
||||
);
|
||||
|
||||
for (let i = 0; i < newMigrations.length; i++) {
|
||||
const file = newMigrations[i];
|
||||
message += color.cyan(`${file.file}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
success(message);
|
||||
}
|
||||
|
||||
module.exports = { listMigrations };
|
Reference in New Issue
Block a user