Skip to content

Commit

Permalink
fix(build): switch to relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Aug 30, 2019
1 parent 100f9ce commit 45a53a9
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/config/args.ts
@@ -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';
Expand Down
10 changes: 5 additions & 5 deletions src/config/index.ts
@@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/config/schema.ts
@@ -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], [
Expand Down
2 changes: 1 addition & 1 deletion src/config/type/Env.ts
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/config/type/Include.ts
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/config/type/Regexp.ts
@@ -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]*)/;

Expand Down
2 changes: 1 addition & 1 deletion src/config/type/Stream.ts
@@ -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',
Expand Down
24 changes: 15 additions & 9 deletions 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;
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/YamlParser.ts
@@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/rule.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/visitor/context.ts
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/visitor/index.ts
@@ -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> {
/**
Expand Down
4 changes: 2 additions & 2 deletions test/TestRule.ts
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion test/harness.ts
@@ -1 +1,3 @@
console.log('test harness');
import sourceMapSupport from 'source-map-support'

sourceMapSupport.install()
4 changes: 2 additions & 2 deletions test/parser/TestYamlParser.ts
@@ -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', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/visitor/TestContext.ts
@@ -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({
Expand Down

0 comments on commit 45a53a9

Please sign in to comment.