fix(build): switch to relative imports
This commit is contained in:
parent
100f9ce9e8
commit
45a53a9821
|
@ -1,6 +1,6 @@
|
|||
import { Options, showCompletionScript, usage } from 'yargs';
|
||||
|
||||
import { VERSION_INFO } from 'src/version';
|
||||
import { VERSION_INFO } from '../version';
|
||||
|
||||
export const CONFIG_ARGS_NAME = 'config-name';
|
||||
export const CONFIG_ARGS_PATH = 'config-path';
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { isNil, isString } from 'lodash';
|
||||
import { join } from 'path';
|
||||
|
||||
import { CONFIG_ENV, CONFIG_SCHEMA } from 'src/config/schema';
|
||||
import { includeSchema } from 'src/config/type/Include';
|
||||
import { NotFoundError } from 'src/error/NotFoundError';
|
||||
import { YamlParser } from 'src/parser/YamlParser';
|
||||
import { readFileSync } from 'src/source';
|
||||
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
|
||||
import { includeSchema } from './type/Include';
|
||||
import { NotFoundError } from '../error/NotFoundError';
|
||||
import { YamlParser } from '../parser/YamlParser';
|
||||
import { readFileSync } from '../source';
|
||||
|
||||
includeSchema.schema = CONFIG_SCHEMA;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { DEFAULT_SAFE_SCHEMA, Schema } from 'js-yaml';
|
||||
|
||||
import { envType } from 'src/config/type/Env';
|
||||
import { includeType } from 'src/config/type/Include';
|
||||
import { regexpType } from 'src/config/type/Regexp';
|
||||
import { streamType } from 'src/config/type/Stream';
|
||||
import { envType } from './type/Env';
|
||||
import { includeType } from './type/Include';
|
||||
import { regexpType } from './type/Regexp';
|
||||
import { streamType } from './type/Stream';
|
||||
|
||||
export const CONFIG_ENV = 'SALTY_HOME';
|
||||
export const CONFIG_SCHEMA = Schema.create([DEFAULT_SAFE_SCHEMA], [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Type as YamlType } from 'js-yaml';
|
||||
|
||||
import { NotFoundError } from 'src/error/NotFoundError';
|
||||
import { NotFoundError } from '../../error/NotFoundError';
|
||||
|
||||
export const envType = new YamlType('!env', {
|
||||
kind: 'scalar',
|
||||
|
|
|
@ -3,7 +3,7 @@ import { SAFE_SCHEMA, safeLoad, Type as YamlType } from 'js-yaml';
|
|||
import { BaseError } from 'noicejs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { NotFoundError } from 'src/error/NotFoundError';
|
||||
import { NotFoundError } from '../../error/NotFoundError';
|
||||
|
||||
// work around the circular dependency by setting the schema later
|
||||
export const includeSchema = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Type as YamlType } from 'js-yaml';
|
||||
import { isNil } from 'lodash';
|
||||
|
||||
import { InvalidArgumentError } from 'src/error/InvalidArgumentError';
|
||||
import { InvalidArgumentError } from '../../error/InvalidArgumentError';
|
||||
|
||||
export const REGEXP_REGEXP = /\/(.*)\/([gimuy]*)/;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Type as YamlType } from 'js-yaml';
|
||||
|
||||
import { NotFoundError } from 'src/error/NotFoundError';
|
||||
import { NotFoundError } from '../../error/NotFoundError';
|
||||
|
||||
const ALLOWED_STREAMS = new Set([
|
||||
'stdout',
|
||||
|
|
24
src/index.ts
24
src/index.ts
|
@ -1,14 +1,20 @@
|
|||
import { createLogger } from 'bunyan';
|
||||
|
||||
import { loadConfig } from 'src/config';
|
||||
import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, parseArgs } from 'src/config/args';
|
||||
import { YamlParser } from 'src/parser/YamlParser';
|
||||
import { loadRules, resolveRules, visitRules } from 'src/rule';
|
||||
import { loadSource, writeSource } from 'src/source';
|
||||
import { VERSION_INFO } from 'src/version';
|
||||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { loadConfig } from './config';
|
||||
import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, parseArgs } from './config/args';
|
||||
import { YamlParser } from './parser/YamlParser';
|
||||
import { loadRules, resolveRules, visitRules } from './rule';
|
||||
import { loadSource, writeSource } from './source';
|
||||
import { VERSION_INFO } from './version';
|
||||
import { VisitorContext } from './visitor/context';
|
||||
|
||||
const MODES = ['check', 'fix', 'list'];
|
||||
enum MODES {
|
||||
check = 'check',
|
||||
fix = 'fix',
|
||||
list = 'list',
|
||||
}
|
||||
|
||||
const MODES_LIST: Array<string> = [MODES.check, MODES.fix, MODES.list];
|
||||
|
||||
const STATUS_SUCCESS = 0;
|
||||
const STATUS_ERROR = 1;
|
||||
|
@ -22,7 +28,7 @@ export async function main(argv: Array<string>): Promise<number> {
|
|||
logger.info({ args }, 'main arguments');
|
||||
|
||||
// check mode
|
||||
if (!MODES.includes(mode)) {
|
||||
if (!MODES_LIST.includes(mode)) {
|
||||
logger.error({ mode }, 'unsupported mode');
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { safeDump, safeLoadAll } from 'js-yaml';
|
||||
|
||||
import { CONFIG_SCHEMA } from 'src/config/schema';
|
||||
import { Parser } from 'src/parser';
|
||||
import { CONFIG_SCHEMA } from '../config/schema';
|
||||
import { Parser } from '../parser';
|
||||
|
||||
export class YamlParser implements Parser {
|
||||
dump(...data: Array<any>): string {
|
||||
|
|
10
src/rule.ts
10
src/rule.ts
|
@ -3,11 +3,11 @@ import { JSONPath } from 'jsonpath-plus';
|
|||
import { cloneDeep, intersection, isNil } from 'lodash';
|
||||
import { LogLevel } from 'noicejs';
|
||||
|
||||
import { YamlParser } from 'src/parser/YamlParser';
|
||||
import { readFileSync } from 'src/source';
|
||||
import { Visitor } from 'src/visitor';
|
||||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { VisitorResult } from 'src/visitor/result';
|
||||
import { YamlParser } from './parser/YamlParser';
|
||||
import { readFileSync } from './source';
|
||||
import { Visitor } from './visitor';
|
||||
import { VisitorContext } from './visitor/context';
|
||||
import { VisitorResult } from './visitor/result';
|
||||
|
||||
export interface RuleData {
|
||||
// metadata
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as Ajv from 'ajv';
|
||||
import { Logger } from 'noicejs';
|
||||
|
||||
import { VisitorResult } from 'src/visitor/result';
|
||||
import { VisitorResult } from './result';
|
||||
|
||||
export interface VisitorContextOptions {
|
||||
coerce: boolean;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { VisitorResult } from 'src/visitor/result';
|
||||
import { VisitorContext } from './context';
|
||||
import { VisitorResult } from './result';
|
||||
|
||||
export interface Visitor<TResult extends VisitorResult> {
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,8 @@ import { expect } from 'chai';
|
|||
import { ConsoleLogger } from 'noicejs';
|
||||
import { mock } from 'sinon';
|
||||
|
||||
import { makeSelector, resolveRules, Rule, visitRules } from 'src/rule';
|
||||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { makeSelector, resolveRules, Rule, visitRules } from '../src/rule';
|
||||
import { VisitorContext } from '../src/visitor/context';
|
||||
|
||||
const TEST_RULES = [new Rule({
|
||||
name: 'foo',
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
console.log('test harness');
|
||||
import sourceMapSupport from 'source-map-support'
|
||||
|
||||
sourceMapSupport.install()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
import { mock } from 'sinon';
|
||||
import { YamlParser } from 'src/parser/YamlParser';
|
||||
|
||||
import { YamlParser } from '../../src/parser/YamlParser';
|
||||
|
||||
describe('yaml parser', () => {
|
||||
describe('dump documents', () => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { expect } from 'chai';
|
||||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { ConsoleLogger } from 'noicejs';
|
||||
|
||||
import { VisitorContext } from '../../src/visitor/context';
|
||||
|
||||
describe('visitor context', () => {
|
||||
it('should merge results', () => {
|
||||
const firstCtx = new VisitorContext({
|
||||
|
|
Loading…
Reference in New Issue