@pikacss/integration 0.0.1 → 0.0.2
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/index.cjs +18 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +19 -5
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -244,7 +244,8 @@ async function createCtx(options) {
|
|
|
244
244
|
fnName,
|
|
245
245
|
transformedFormat,
|
|
246
246
|
tsCodegen,
|
|
247
|
-
devCss
|
|
247
|
+
devCss,
|
|
248
|
+
autoCreateConfig
|
|
248
249
|
} = options;
|
|
249
250
|
const devCssFilepath = pathe.isAbsolute(devCss) ? pathe.resolve(devCss) : pathe.join(cwd, devCss);
|
|
250
251
|
const tsCodegenFilepath = tsCodegen === false ? null : pathe.isAbsolute(tsCodegen) ? pathe.resolve(tsCodegen) : pathe.join(cwd, tsCodegen);
|
|
@@ -273,12 +274,25 @@ async function createCtx(options) {
|
|
|
273
274
|
loadConfig: async () => {
|
|
274
275
|
if (inlineConfig != null)
|
|
275
276
|
return { config: inlineConfig, file: null };
|
|
276
|
-
|
|
277
|
+
let resolvedConfigPath = configSources.find((path) => {
|
|
277
278
|
const stat = node_fs.statSync(path, { throwIfNoEntry: false });
|
|
278
279
|
return stat != null && stat.isFile();
|
|
279
280
|
});
|
|
280
|
-
if (resolvedConfigPath == null)
|
|
281
|
-
|
|
281
|
+
if (resolvedConfigPath == null) {
|
|
282
|
+
if (autoCreateConfig === false)
|
|
283
|
+
return { config: null, file: null };
|
|
284
|
+
resolvedConfigPath = configSources[0];
|
|
285
|
+
await promises.mkdir(pathe.dirname(resolvedConfigPath), { recursive: true }).catch(() => {
|
|
286
|
+
});
|
|
287
|
+
const from = tsCodegenFilepath == null ? currentPackageName : `./${pathe.relative(pathe.dirname(resolvedConfigPath), tsCodegenFilepath)}`;
|
|
288
|
+
await promises.writeFile(resolvedConfigPath, [
|
|
289
|
+
`import { defineEngineConfig } from '${from}'`,
|
|
290
|
+
"",
|
|
291
|
+
"export default defineEngineConfig({",
|
|
292
|
+
" // Add your PikaCSS engine config here",
|
|
293
|
+
"})"
|
|
294
|
+
].join("\n"));
|
|
295
|
+
}
|
|
282
296
|
const jiti$1 = jiti.createJiti(cwd, {
|
|
283
297
|
fsCache: false,
|
|
284
298
|
moduleCache: false
|
package/dist/index.d.cts
CHANGED
|
@@ -67,6 +67,7 @@ interface IntegrationContextOptions {
|
|
|
67
67
|
transformedFormat: 'string' | 'array' | 'inline';
|
|
68
68
|
tsCodegen: false | string;
|
|
69
69
|
devCss: string;
|
|
70
|
+
autoCreateConfig: boolean;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
declare function createCtx(options: IntegrationContextOptions): Promise<IntegrationContext>;
|
package/dist/index.d.mts
CHANGED
|
@@ -67,6 +67,7 @@ interface IntegrationContextOptions {
|
|
|
67
67
|
transformedFormat: 'string' | 'array' | 'inline';
|
|
68
68
|
tsCodegen: false | string;
|
|
69
69
|
devCss: string;
|
|
70
|
+
autoCreateConfig: boolean;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
declare function createCtx(options: IntegrationContextOptions): Promise<IntegrationContext>;
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ interface IntegrationContextOptions {
|
|
|
67
67
|
transformedFormat: 'string' | 'array' | 'inline';
|
|
68
68
|
tsCodegen: false | string;
|
|
69
69
|
devCss: string;
|
|
70
|
+
autoCreateConfig: boolean;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
declare function createCtx(options: IntegrationContextOptions): Promise<IntegrationContext>;
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { createJiti } from 'jiti';
|
|
|
6
6
|
import { isPackageExists } from 'local-pkg';
|
|
7
7
|
import MagicString from 'magic-string';
|
|
8
8
|
import micromatch from 'micromatch';
|
|
9
|
-
import { isAbsolute, resolve, join, dirname } from 'pathe';
|
|
9
|
+
import { isAbsolute, resolve, join, dirname, relative } from 'pathe';
|
|
10
10
|
import * as prettier from 'prettier';
|
|
11
11
|
|
|
12
12
|
function createEventHook() {
|
|
@@ -225,7 +225,8 @@ async function createCtx(options) {
|
|
|
225
225
|
fnName,
|
|
226
226
|
transformedFormat,
|
|
227
227
|
tsCodegen,
|
|
228
|
-
devCss
|
|
228
|
+
devCss,
|
|
229
|
+
autoCreateConfig
|
|
229
230
|
} = options;
|
|
230
231
|
const devCssFilepath = isAbsolute(devCss) ? resolve(devCss) : join(cwd, devCss);
|
|
231
232
|
const tsCodegenFilepath = tsCodegen === false ? null : isAbsolute(tsCodegen) ? resolve(tsCodegen) : join(cwd, tsCodegen);
|
|
@@ -254,12 +255,25 @@ async function createCtx(options) {
|
|
|
254
255
|
loadConfig: async () => {
|
|
255
256
|
if (inlineConfig != null)
|
|
256
257
|
return { config: inlineConfig, file: null };
|
|
257
|
-
|
|
258
|
+
let resolvedConfigPath = configSources.find((path) => {
|
|
258
259
|
const stat = statSync(path, { throwIfNoEntry: false });
|
|
259
260
|
return stat != null && stat.isFile();
|
|
260
261
|
});
|
|
261
|
-
if (resolvedConfigPath == null)
|
|
262
|
-
|
|
262
|
+
if (resolvedConfigPath == null) {
|
|
263
|
+
if (autoCreateConfig === false)
|
|
264
|
+
return { config: null, file: null };
|
|
265
|
+
resolvedConfigPath = configSources[0];
|
|
266
|
+
await mkdir(dirname(resolvedConfigPath), { recursive: true }).catch(() => {
|
|
267
|
+
});
|
|
268
|
+
const from = tsCodegenFilepath == null ? currentPackageName : `./${relative(dirname(resolvedConfigPath), tsCodegenFilepath)}`;
|
|
269
|
+
await writeFile(resolvedConfigPath, [
|
|
270
|
+
`import { defineEngineConfig } from '${from}'`,
|
|
271
|
+
"",
|
|
272
|
+
"export default defineEngineConfig({",
|
|
273
|
+
" // Add your PikaCSS engine config here",
|
|
274
|
+
"})"
|
|
275
|
+
].join("\n"));
|
|
276
|
+
}
|
|
263
277
|
const jiti = createJiti(cwd, {
|
|
264
278
|
fsCache: false,
|
|
265
279
|
moduleCache: false
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.2",
|
|
8
8
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"fast-glob": "
|
|
38
|
-
"jiti": "
|
|
39
|
-
"local-pkg": "
|
|
40
|
-
"magic-string": "
|
|
41
|
-
"micromatch": "
|
|
42
|
-
"pathe": "
|
|
43
|
-
"prettier": "
|
|
44
|
-
"@pikacss/core": "0.0.
|
|
37
|
+
"fast-glob": "catalog:",
|
|
38
|
+
"jiti": "catalog:",
|
|
39
|
+
"local-pkg": "catalog:",
|
|
40
|
+
"magic-string": "catalog:",
|
|
41
|
+
"micromatch": "catalog:",
|
|
42
|
+
"pathe": "catalog:",
|
|
43
|
+
"prettier": "catalog:",
|
|
44
|
+
"@pikacss/core": "0.0.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/micromatch": "
|
|
47
|
+
"@types/micromatch": "catalog:"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "unbuild",
|