From b32fd69bdf0a71ebe729bb645d2a22f7435bec9e Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Tue, 18 Apr 2023 07:11:05 -0300 Subject: [PATCH] Publish fixes (#217) * move lib folder to src. * fix publishing * export types * move nem-fs to dependencies. mem-fs is now required due to types and conflicts with v2 types. Since peerDependencies overrides dependencies, we cannot have peerDependencies safeguard anymore if we allow mem-fs-editor to run with mem-fs v2. --- __tests__/append-tpl.spec.ts | 2 +- __tests__/append.spec.ts | 2 +- __tests__/commit-file-async.spec.ts | 2 +- __tests__/commit.spec.ts | 4 ++-- __tests__/copy-async.spec.ts | 2 +- __tests__/copy-tpl-async.spec.ts | 2 +- __tests__/copy-tpl.spec.ts | 4 ++-- __tests__/copy.spec.ts | 2 +- __tests__/delete.spec.ts | 2 +- __tests__/dump.spec.ts | 2 +- __tests__/exists.spec.ts | 2 +- __tests__/extend-json.spec.ts | 2 +- __tests__/move.spec.ts | 2 +- __tests__/read-json.spec.ts | 2 +- __tests__/read.spec.ts | 2 +- __tests__/state.spec.ts | 2 +- __tests__/util.spec.ts | 2 +- __tests__/write-json.spec.ts | 2 +- __tests__/write.spec.ts | 2 +- package-lock.json | 9 +-------- package.json | 11 ++--------- {lib => src}/actions/append-tpl.ts | 0 {lib => src}/actions/append.ts | 0 {lib => src}/actions/commit-file-async.ts | 0 {lib => src}/actions/commit.ts | 0 {lib => src}/actions/copy-async.ts | 0 {lib => src}/actions/copy-tpl-async.ts | 0 {lib => src}/actions/copy-tpl.ts | 0 {lib => src}/actions/copy.ts | 0 {lib => src}/actions/delete.ts | 0 {lib => src}/actions/dump.ts | 0 {lib => src}/actions/exists.ts | 0 {lib => src}/actions/extend-json.ts | 0 {lib => src}/actions/move.ts | 0 {lib => src}/actions/read-json.ts | 0 {lib => src}/actions/read.ts | 0 {lib => src}/actions/write-json.ts | 0 {lib => src}/actions/write.ts | 0 {lib => src}/index.ts | 5 +++++ {lib => src}/state.ts | 0 {lib => src}/transform.ts | 0 {lib => src}/util.ts | 0 tsconfig.json | 4 ++-- 43 files changed, 31 insertions(+), 40 deletions(-) rename {lib => src}/actions/append-tpl.ts (100%) rename {lib => src}/actions/append.ts (100%) rename {lib => src}/actions/commit-file-async.ts (100%) rename {lib => src}/actions/commit.ts (100%) rename {lib => src}/actions/copy-async.ts (100%) rename {lib => src}/actions/copy-tpl-async.ts (100%) rename {lib => src}/actions/copy-tpl.ts (100%) rename {lib => src}/actions/copy.ts (100%) rename {lib => src}/actions/delete.ts (100%) rename {lib => src}/actions/dump.ts (100%) rename {lib => src}/actions/exists.ts (100%) rename {lib => src}/actions/extend-json.ts (100%) rename {lib => src}/actions/move.ts (100%) rename {lib => src}/actions/read-json.ts (100%) rename {lib => src}/actions/read.ts (100%) rename {lib => src}/actions/write-json.ts (100%) rename {lib => src}/actions/write.ts (100%) rename {lib => src}/index.ts (92%) rename {lib => src}/state.ts (100%) rename {lib => src}/transform.ts (100%) rename {lib => src}/util.ts (100%) diff --git a/__tests__/append-tpl.spec.ts b/__tests__/append-tpl.spec.ts index 7d695bf..a2441e7 100644 --- a/__tests__/append-tpl.spec.ts +++ b/__tests__/append-tpl.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/append.spec.ts b/__tests__/append.spec.ts index f2cc16d..e81b552 100644 --- a/__tests__/append.spec.ts +++ b/__tests__/append.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; -import { MemFsEditor, create } from '../lib/index.js'; +import { MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; describe('#write()', () => { diff --git a/__tests__/commit-file-async.spec.ts b/__tests__/commit-file-async.spec.ts index 428bbd0..70487bc 100644 --- a/__tests__/commit-file-async.spec.ts +++ b/__tests__/commit-file-async.spec.ts @@ -4,7 +4,7 @@ import os from 'os'; import path from 'path'; import { create as createMemFs } from 'mem-fs'; import sinon from 'sinon'; -import { type MemFsEditor, type MemFsEditorFile, create } from '../lib/index.js'; +import { type MemFsEditor, type MemFsEditorFile, create } from '../src/index.js'; const rmSync = filesystem.rmSync || filesystem.rmdirSync; diff --git a/__tests__/commit.spec.ts b/__tests__/commit.spec.ts index ebd3cd1..0ff71a6 100644 --- a/__tests__/commit.spec.ts +++ b/__tests__/commit.spec.ts @@ -4,8 +4,8 @@ import os from 'os'; import path from 'path'; import { create as createMemFs } from 'mem-fs'; import sinon from 'sinon'; -import { MemFsEditor, create } from '../lib/index.js'; -import { createTransform } from '../lib/transform.js'; +import { MemFsEditor, create } from '../src/index.js'; +import { createTransform } from '../src/transform.js'; import { getFixture } from './fixtures.js'; const rmSync = filesystem.rmSync || filesystem.rmdirSync; diff --git a/__tests__/copy-async.spec.ts b/__tests__/copy-async.spec.ts index 8029939..938e633 100644 --- a/__tests__/copy-async.spec.ts +++ b/__tests__/copy-async.spec.ts @@ -3,7 +3,7 @@ import filesystem from 'fs'; import os from 'os'; import path from 'path'; import sinon from 'sinon'; -import { MemFsEditor, create } from '../lib/index.js'; +import { MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/copy-tpl-async.spec.ts b/__tests__/copy-tpl-async.spec.ts index 4e85712..0c723c0 100644 --- a/__tests__/copy-tpl-async.spec.ts +++ b/__tests__/copy-tpl-async.spec.ts @@ -1,7 +1,7 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; import path from 'path'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import normalize from 'normalize-path'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/copy-tpl.spec.ts b/__tests__/copy-tpl.spec.ts index 9bdd5a9..5506410 100644 --- a/__tests__/copy-tpl.spec.ts +++ b/__tests__/copy-tpl.spec.ts @@ -1,11 +1,11 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; import path from 'path'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import normalize from 'normalize-path'; import { getFixture } from './fixtures.js'; -import { CopyOptions } from '../lib/actions/copy.js'; +import { CopyOptions } from '../src/actions/copy.js'; describe('#copyTpl()', () => { let store; diff --git a/__tests__/copy.spec.ts b/__tests__/copy.spec.ts index a525dd7..6326209 100644 --- a/__tests__/copy.spec.ts +++ b/__tests__/copy.spec.ts @@ -3,7 +3,7 @@ import filesystem from 'fs'; import os from 'os'; import path, { dirname } from 'path'; import sinon from 'sinon'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; import { fileURLToPath } from 'url'; diff --git a/__tests__/delete.spec.ts b/__tests__/delete.spec.ts index ddb7282..6d496c9 100644 --- a/__tests__/delete.spec.ts +++ b/__tests__/delete.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import path from 'path'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/dump.spec.ts b/__tests__/dump.spec.ts index f5638ec..4afd360 100644 --- a/__tests__/dump.spec.ts +++ b/__tests__/dump.spec.ts @@ -3,7 +3,7 @@ import filesystem from 'fs'; import os from 'os'; import path from 'path'; import { create as createMemFs } from 'mem-fs'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; const rmSync = filesystem.rmSync || filesystem.rmdirSync; diff --git a/__tests__/exists.spec.ts b/__tests__/exists.spec.ts index 4534e84..7dc781a 100644 --- a/__tests__/exists.spec.ts +++ b/__tests__/exists.spec.ts @@ -1,5 +1,5 @@ import { describe, beforeEach, it, expect } from 'vitest'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/extend-json.spec.ts b/__tests__/extend-json.spec.ts index 3120c0e..57a9c64 100644 --- a/__tests__/extend-json.spec.ts +++ b/__tests__/extend-json.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it } from 'vitest'; import sinon from 'sinon'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/move.spec.ts b/__tests__/move.spec.ts index 2fdd36e..39dbdde 100644 --- a/__tests__/move.spec.ts +++ b/__tests__/move.spec.ts @@ -1,7 +1,7 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; import path from 'path'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/read-json.spec.ts b/__tests__/read-json.spec.ts index 619adde..fc0cfbd 100644 --- a/__tests__/read-json.spec.ts +++ b/__tests__/read-json.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import sinon from 'sinon'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import escape from 'escape-regexp'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/read.spec.ts b/__tests__/read.spec.ts index 8ff9798..35e0646 100644 --- a/__tests__/read.spec.ts +++ b/__tests__/read.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import os from 'os'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/state.spec.ts b/__tests__/state.spec.ts index 63c0c16..45dbb72 100644 --- a/__tests__/state.spec.ts +++ b/__tests__/state.spec.ts @@ -14,7 +14,7 @@ import { setCommittedFile, setDeletedFileState, setModifiedFileState, -} from '../lib/state.js'; +} from '../src/state.js'; describe('state', () => { let file; diff --git a/__tests__/util.spec.ts b/__tests__/util.spec.ts index 8605b75..14c11c3 100644 --- a/__tests__/util.spec.ts +++ b/__tests__/util.spec.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest'; import filesystem from 'fs'; import path from 'path'; import sinon from 'sinon'; -import { getCommonPath, globify } from '../lib/util.js'; +import { getCommonPath, globify } from '../src/util.js'; import normalize from 'normalize-path'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/write-json.spec.ts b/__tests__/write-json.spec.ts index c9cf523..c4a35ca 100644 --- a/__tests__/write-json.spec.ts +++ b/__tests__/write-json.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import sinon from 'sinon'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/__tests__/write.spec.ts b/__tests__/write.spec.ts index eee392f..1a7c1f9 100644 --- a/__tests__/write.spec.ts +++ b/__tests__/write.spec.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect } from 'vitest'; import sinon from 'sinon'; -import { type MemFsEditor, create } from '../lib/index.js'; +import { type MemFsEditor, create } from '../src/index.js'; import { create as createMemFs } from 'mem-fs'; import { getFixture } from './fixtures.js'; diff --git a/package-lock.json b/package-lock.json index 811d66c..afb5e80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "ejs": "^3.1.9", "globby": "^13.1.4", "isbinaryfile": "^5.0.0", + "mem-fs": "^3.0.0", "minimatch": "^9.0.0", "multimatch": "^6.0.0", "normalize-path": "^3.0.0", @@ -37,14 +38,6 @@ }, "engines": { "node": ">=12.10.0" - }, - "peerDependencies": { - "mem-fs": "^2.1.0" - }, - "peerDependenciesMeta": { - "mem-fs": { - "optional": true - } } }, "node_modules/@esbuild/android-arm": { diff --git a/package.json b/package.json index 7db9a09..9bccd3d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ } }, "files": [ - "lib" + "dist" ], "dependencies": { "@types/ejs": "^3.1.2", @@ -40,20 +40,13 @@ "ejs": "^3.1.9", "globby": "^13.1.4", "isbinaryfile": "^5.0.0", + "mem-fs": "^3.0.0", "minimatch": "^9.0.0", "multimatch": "^6.0.0", "normalize-path": "^3.0.0", "textextensions": "^5.13.0", "vinyl": "^3.0.0" }, - "peerDependencies": { - "mem-fs": "^2.1.0" - }, - "peerDependenciesMeta": { - "mem-fs": { - "optional": true - } - }, "devDependencies": { "coveralls": "^3.0.3", "escape-regexp": "0.0.1", diff --git a/lib/actions/append-tpl.ts b/src/actions/append-tpl.ts similarity index 100% rename from lib/actions/append-tpl.ts rename to src/actions/append-tpl.ts diff --git a/lib/actions/append.ts b/src/actions/append.ts similarity index 100% rename from lib/actions/append.ts rename to src/actions/append.ts diff --git a/lib/actions/commit-file-async.ts b/src/actions/commit-file-async.ts similarity index 100% rename from lib/actions/commit-file-async.ts rename to src/actions/commit-file-async.ts diff --git a/lib/actions/commit.ts b/src/actions/commit.ts similarity index 100% rename from lib/actions/commit.ts rename to src/actions/commit.ts diff --git a/lib/actions/copy-async.ts b/src/actions/copy-async.ts similarity index 100% rename from lib/actions/copy-async.ts rename to src/actions/copy-async.ts diff --git a/lib/actions/copy-tpl-async.ts b/src/actions/copy-tpl-async.ts similarity index 100% rename from lib/actions/copy-tpl-async.ts rename to src/actions/copy-tpl-async.ts diff --git a/lib/actions/copy-tpl.ts b/src/actions/copy-tpl.ts similarity index 100% rename from lib/actions/copy-tpl.ts rename to src/actions/copy-tpl.ts diff --git a/lib/actions/copy.ts b/src/actions/copy.ts similarity index 100% rename from lib/actions/copy.ts rename to src/actions/copy.ts diff --git a/lib/actions/delete.ts b/src/actions/delete.ts similarity index 100% rename from lib/actions/delete.ts rename to src/actions/delete.ts diff --git a/lib/actions/dump.ts b/src/actions/dump.ts similarity index 100% rename from lib/actions/dump.ts rename to src/actions/dump.ts diff --git a/lib/actions/exists.ts b/src/actions/exists.ts similarity index 100% rename from lib/actions/exists.ts rename to src/actions/exists.ts diff --git a/lib/actions/extend-json.ts b/src/actions/extend-json.ts similarity index 100% rename from lib/actions/extend-json.ts rename to src/actions/extend-json.ts diff --git a/lib/actions/move.ts b/src/actions/move.ts similarity index 100% rename from lib/actions/move.ts rename to src/actions/move.ts diff --git a/lib/actions/read-json.ts b/src/actions/read-json.ts similarity index 100% rename from lib/actions/read-json.ts rename to src/actions/read-json.ts diff --git a/lib/actions/read.ts b/src/actions/read.ts similarity index 100% rename from lib/actions/read.ts rename to src/actions/read.ts diff --git a/lib/actions/write-json.ts b/src/actions/write-json.ts similarity index 100% rename from lib/actions/write-json.ts rename to src/actions/write-json.ts diff --git a/lib/actions/write.ts b/src/actions/write.ts similarity index 100% rename from lib/actions/write.ts rename to src/actions/write.ts diff --git a/lib/index.ts b/src/index.ts similarity index 92% rename from lib/index.ts rename to src/index.ts index a44dad2..b013535 100644 --- a/lib/index.ts +++ b/src/index.ts @@ -19,6 +19,11 @@ import commit from './actions/commit.js'; import commitFileAsync from './actions/commit-file-async.js'; import dump from './actions/dump.js'; +export type { AppendOptions } from './actions/append.js'; +export type { CopyOptions } from './actions/copy.js'; +export type { CopyAsyncOptions } from './actions/copy-async.js'; +export type { MemFsEditorFileDump } from './actions/dump.js'; + export interface MemFsEditorFile { path: string; stat?: { mode?: number } | null; diff --git a/lib/state.ts b/src/state.ts similarity index 100% rename from lib/state.ts rename to src/state.ts diff --git a/lib/transform.ts b/src/transform.ts similarity index 100% rename from lib/transform.ts rename to src/transform.ts diff --git a/lib/util.ts b/src/util.ts similarity index 100% rename from lib/util.ts rename to src/util.ts diff --git a/tsconfig.json b/tsconfig.json index a7942a7..dfc6273 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["lib/**/*"], + "include": ["src/**/*"], "compilerOptions": { /* Language and Environment */ "target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, @@ -10,7 +10,7 @@ /* Modules */ "module": "node16" /* Specify what module code is generated. */, - "rootDir": "./lib" /* Specify the root folder within your source files. */, + "rootDir": "./src" /* Specify the root folder within your source files. */, "resolveJsonModule": true, /* JavaScript Support */