tailwindcss-patch 1.1.0-rc.0 → 1.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var patcher = require('./patcher-75f59039.js');
3
+ var patcher = require('./patcher-8dfb86e3.js');
4
4
  require('path');
5
5
  require('fs');
6
6
  require('semver');
@@ -10,5 +10,6 @@ require('@babel/parser');
10
10
  require('@babel/traverse');
11
11
  require('resolve');
12
12
 
13
- const patch = patcher.createPatch();
13
+ const opt = patcher.getPatchOptions();
14
+ const patch = patcher.createPatch(opt);
14
15
  patch();
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
6
  var fs = require('fs');
7
- var patcher = require('./patcher-75f59039.js');
7
+ var patcher = require('./patcher-8dfb86e3.js');
8
8
  require('semver');
9
9
  require('@babel/types');
10
10
  require('@babel/generator');
@@ -67,7 +67,7 @@ function mkCacheDirectory(cacheDirectory) {
67
67
  }
68
68
  return cacheDirectory;
69
69
  }
70
- function getCacheOptions(options = {}) {
70
+ function getCacheOptions$1(options = {}) {
71
71
  var _a, _b, _c;
72
72
  const cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
73
73
  const dir = (_b = options.dir) !== null && _b !== void 0 ? _b : path__default["default"].resolve(cwd, 'node_modules/.cache', pkgName);
@@ -82,7 +82,7 @@ function getCacheOptions(options = {}) {
82
82
  }
83
83
  function writeCache(data, options = {}) {
84
84
  try {
85
- const { dir, filename } = getCacheOptions(options);
85
+ const { dir, filename } = getCacheOptions$1(options);
86
86
  mkCacheDirectory(dir);
87
87
  fs__default["default"].writeFileSync(filename, JSON.stringify(Array.from(data), null, 2), 'utf-8');
88
88
  return filename;
@@ -92,7 +92,7 @@ function writeCache(data, options = {}) {
92
92
  }
93
93
  }
94
94
  function readCache(options = {}) {
95
- const { filename } = getCacheOptions(options);
95
+ const { filename } = getCacheOptions$1(options);
96
96
  try {
97
97
  if (fs__default["default"].existsSync(filename)) {
98
98
  const data = fs__default["default"].readFileSync(filename, 'utf-8');
@@ -110,31 +110,34 @@ function readCache(options = {}) {
110
110
  }
111
111
  }
112
112
 
113
+ function getCacheOptions(options) {
114
+ let cache;
115
+ switch (typeof options) {
116
+ case 'undefined': {
117
+ cache = {
118
+ enable: false
119
+ };
120
+ break;
121
+ }
122
+ case 'boolean': {
123
+ cache = {
124
+ enable: options
125
+ };
126
+ break;
127
+ }
128
+ case 'object': {
129
+ cache = Object.assign(Object.assign({}, options), { enable: true });
130
+ break;
131
+ }
132
+ }
133
+ return cache;
134
+ }
113
135
  class TailwindcssPatcher {
114
136
  constructor(options = {}) {
115
137
  this.rawOptions = options;
116
- let cache;
117
- switch (typeof options.cache) {
118
- case 'undefined': {
119
- cache = {
120
- enable: false
121
- };
122
- break;
123
- }
124
- case 'boolean': {
125
- cache = {
126
- enable: options.cache
127
- };
128
- break;
129
- }
130
- case 'object': {
131
- cache = Object.assign(Object.assign({}, options.cache), { enable: true });
132
- break;
133
- }
134
- }
135
- this.cacheOptions = cache;
136
- this.patchOptions = options.patch;
137
- this.patch = patcher.createPatch(options.patch);
138
+ this.cacheOptions = getCacheOptions(options.cache);
139
+ this.patchOptions = patcher.getPatchOptions(options.patch);
140
+ this.patch = patcher.createPatch(this.patchOptions);
138
141
  }
139
142
  getPkgEntry(basedir) {
140
143
  return getTailwindcssEntry(basedir);
@@ -160,12 +163,14 @@ class TailwindcssPatcher {
160
163
  exports.createPatch = patcher.createPatch;
161
164
  exports.ensureFileContent = patcher.ensureFileContent;
162
165
  exports.getInstalledPkgJsonPath = patcher.getInstalledPkgJsonPath;
166
+ exports.getPatchOptions = patcher.getPatchOptions;
163
167
  exports.inspectPostcssPlugin = patcher.inspectPostcssPlugin;
164
168
  exports.inspectProcessTailwindFeaturesReturnContext = patcher.inspectProcessTailwindFeaturesReturnContext;
165
169
  exports.internalPatch = patcher.internalPatch;
166
170
  exports.monkeyPatchForExposingContext = patcher.monkeyPatchForExposingContext;
167
171
  exports.requireResolve = patcher.requireResolve;
168
172
  exports.TailwindcssPatcher = TailwindcssPatcher;
173
+ exports.getCacheOptions = getCacheOptions;
169
174
  exports.getClassCacheSet = getClassCacheSet;
170
175
  exports.getClassCaches = getClassCaches;
171
176
  exports.getContexts = getContexts;
@@ -240,10 +240,12 @@ function getInstalledPkgJsonPath(options = {}) {
240
240
  }
241
241
  }
242
242
  }
243
- function createPatch(options = {}) {
244
- const opt = defu(options, {
243
+ function getPatchOptions(options = {}) {
244
+ return defu(options, {
245
245
  basedir: process.cwd()
246
246
  }, defaultOptions);
247
+ }
248
+ function createPatch(opt) {
247
249
  return () => {
248
250
  try {
249
251
  const pkgJsonPath = getInstalledPkgJsonPath(opt);
@@ -298,6 +300,7 @@ function internalPatch(pkgJsonPath, options) {
298
300
  exports.createPatch = createPatch;
299
301
  exports.ensureFileContent = ensureFileContent;
300
302
  exports.getInstalledPkgJsonPath = getInstalledPkgJsonPath;
303
+ exports.getPatchOptions = getPatchOptions;
301
304
  exports.inspectPostcssPlugin = inspectPostcssPlugin;
302
305
  exports.inspectProcessTailwindFeaturesReturnContext = inspectProcessTailwindFeaturesReturnContext;
303
306
  exports.internalPatch = internalPatch;
@@ -1,12 +1,13 @@
1
- import type { InternalCacheOptions, PatchOptions } from './type';
1
+ import type { CacheOptions, PatchOptions, InternalCacheOptions, InternalPatchOptions } from './type';
2
2
  export interface TailwindcssPatcherOptions {
3
- cache?: InternalCacheOptions;
3
+ cache?: CacheOptions;
4
4
  patch?: PatchOptions;
5
5
  }
6
+ export declare function getCacheOptions(options?: CacheOptions): InternalCacheOptions;
6
7
  export declare class TailwindcssPatcher {
7
8
  rawOptions: TailwindcssPatcherOptions;
8
9
  cacheOptions: InternalCacheOptions;
9
- patchOptions?: PatchOptions;
10
+ patchOptions: InternalPatchOptions;
10
11
  patch: () => void;
11
12
  constructor(options?: TailwindcssPatcherOptions);
12
13
  getPkgEntry(basedir?: string): string;
@@ -1,6 +1,7 @@
1
1
  import type { PatchOptions, InternalPatchOptions } from './type';
2
2
  export declare function getInstalledPkgJsonPath(options?: PatchOptions): string | undefined;
3
- export declare function createPatch(options?: PatchOptions): () => any;
3
+ export declare function getPatchOptions(options?: PatchOptions): InternalPatchOptions;
4
+ export declare function createPatch(opt: InternalPatchOptions): () => any;
4
5
  export declare function monkeyPatchForExposingContext(twDir: string, opt: InternalPatchOptions): {
5
6
  processTailwindFeatures?: string | undefined;
6
7
  plugin?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "1.1.0-rc.0",
3
+ "version": "1.1.0-rc.1",
4
4
  "description": "patch tailwindcss for exposing context",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",