Skip to content

Commit

Permalink
chore: move and rename some files
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Sep 1, 2021
1 parent f3297ac commit 53c423d
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/comment-parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseComment } from '../utils/comment-parser';
import { parseComment } from '../lib/comment-parser';

const template = `/*
* @vuepress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fs, vol } from 'memfs';

import { getFileStructure } from '../utils/file-structure';
import { listFolder } from '../lib/list-folder';

jest.mock('fs');
jest.mock('fs/promises', () => fs.promises);
Expand All @@ -21,7 +21,7 @@ describe('test file-structure', () => {
'./src'
);

expect(await getFileStructure('./src', [])).toEqual([
expect(await listFolder('./src', [])).toEqual([
{ ext: '.js', folder: 'src/', isDir: false, name: 'file1', path: 'src/file1.js' },
{ ext: '.ts', folder: 'src/', isDir: false, name: 'file2', path: 'src/file2.ts' },
{ ext: '.vue', folder: 'src/lib/', isDir: false, name: 'file3', path: 'src/lib/file3.vue' },
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/sidebar.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateVueSidebar } from '../utils/vue-sidebar';
import { generateVueSidebar } from '../lib/vue-sidebar';

describe('test sidebar', () => {
test('generateVueSidebar should return valid vue config', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkExtension, getExtension, getFilename, asyncForEach } from '../utils';
import { checkExtension, getExtension, getFilename, asyncForEach } from '../lib/utils';

describe('test utils', () => {
test('getExtension should return true', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import del from 'del';
import mkdirp from 'mkdirp';

import { parseFile, parseVueFile, writeContentToFile } from './parser';
import { getExtension } from './utils';
import { getFileStructure } from './utils/file-structure';
import { listFolder } from './lib/list-folder';
import { parseFile, parseVueFile, writeContentToFile } from './lib/parser';
import { getExtension } from './lib/utils';

const fileTree: any[] = [];
const statistics: Record<string, any> = {};
Expand Down Expand Up @@ -50,7 +50,7 @@ export const generate = async (argv: Record<string, string>) => {
// remove docs folder, except README.md
const deletedPaths = await del([`${docsFolder}/**/*`, `!${docsFolder}/README.md`, ...rmPattern]);

const filesAndFolder = await getFileStructure(srcFolder, exclude);
const filesAndFolder = await listFolder(srcFolder, exclude);

await mkdirp(docsFolder);

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/utils/file-structure.ts → src/lib/list-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';

import { DirectoryFile } from '../interfaces';

export const getFileStructure = async (srcPath: string, exclude: string[] = [], mainPath?: string) => {
export const listFolder = async (srcPath: string, exclude: string[] = [], mainPath?: string) => {
const paths: DirectoryFile[] = [];
const dirs = await fs.readdir(srcPath, {
withFileTypes: true
Expand All @@ -19,7 +19,7 @@ export const getFileStructure = async (srcPath: string, exclude: string[] = [],

if (!mm.isMatch(path.join(srcPath.replace(mainPath || srcPath, ''), dirent.name), exclude)) {
if (isDir) {
paths.push(...(await getFileStructure(filePath, exclude, mainPath || srcPath)));
paths.push(...(await listFolder(filePath, exclude, mainPath || srcPath)));
}

if (name === 'index') {
Expand Down
5 changes: 3 additions & 2 deletions src/parser.ts → src/lib/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import path from 'path';
import compileTemplates from 'vue-docgen-cli/lib/compileTemplates';
import { extractConfig } from 'vue-docgen-cli/lib/docgen';

import { DirectoryFile } from './interfaces';
import { parseVuepressFileHeader } from './utils/comment-parser';
import { DirectoryFile } from '../interfaces';

import { parseVuepressFileHeader } from './comment-parser';

interface ParseReturn {
dest: string;
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 53c423d

Please sign in to comment.