auklet 0.0.11 → 0.0.12

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.
@@ -1,6 +1,5 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
- import { emptyModuleEntryComment } from '#auklet/css/production/format/shared';
2
+ import { writeStyleFile } from '#auklet/css/production/format/shared';
4
3
  import { toPosixPath } from '#auklet/utils';
5
4
  export class ComponentStyleEntryWriter {
6
5
  config;
@@ -36,12 +35,9 @@ export class ComponentStyleEntryWriter {
36
35
  this.resolver.toOutputStyleSpecifier(specifier, outRoot),
37
36
  );
38
37
  }
39
- fs.mkdirSync(styleDir, { recursive: true });
40
- fs.writeFileSync(
38
+ writeStyleFile(
41
39
  target,
42
- root.nodes?.length
43
- ? this.styleProcessor.stringify(root)
44
- : emptyModuleEntryComment,
40
+ root.nodes?.length ? this.styleProcessor.stringify(root) : '',
45
41
  );
46
42
  outputs.push(target);
47
43
  }
@@ -1,7 +1,9 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
2
  import { createStyleEntryParts } from '#auklet/css/core/style/entries';
4
- import { toRelativeImportSpecifier } from '#auklet/css/production/format/shared';
3
+ import {
4
+ writeStyleFile,
5
+ toRelativeImportSpecifier,
6
+ } from '#auklet/css/production/format/shared';
5
7
  export class StyleEntryWriter {
6
8
  config;
7
9
  packageContext;
@@ -47,8 +49,7 @@ export class StyleEntryWriter {
47
49
  }
48
50
  }
49
51
  if (!root.nodes?.length) return null;
50
- fs.mkdirSync(path.dirname(target), { recursive: true });
51
- fs.writeFileSync(target, this.styleProcessor.stringify(root));
52
+ writeStyleFile(target, this.styleProcessor.stringify(root));
52
53
  return target;
53
54
  }
54
55
  }
@@ -1,4 +1,4 @@
1
- import type { FormatWriterOptions } from '#auklet/css/production/format/shared';
1
+ import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
2
2
  export declare class ExternalStyleWriter {
3
3
  private readonly config;
4
4
  private readonly packageContext;
@@ -1,6 +1,6 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
2
  import { createExternalEntryParts } from '#auklet/css/core/style/entries';
3
+ import { writeStyleFile } from '#auklet/css/production/format/shared';
4
4
  export class ExternalStyleWriter {
5
5
  config;
6
6
  packageContext;
@@ -29,8 +29,7 @@ export class ExternalStyleWriter {
29
29
  );
30
30
  }
31
31
  }
32
- fs.mkdirSync(path.dirname(target), { recursive: true });
33
- fs.writeFileSync(
32
+ writeStyleFile(
34
33
  target,
35
34
  root.nodes?.length ? this.styleProcessor.stringify(root) : '',
36
35
  );
@@ -1,4 +1,4 @@
1
- import type { FormatWriterOptions } from '#auklet/css/production/format/shared';
1
+ import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
2
2
  export declare class ModuleStyleWriter {
3
3
  private readonly config;
4
4
  private readonly packageContext;
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
2
+ import { writeStyleFile } from '#auklet/css/production/format/shared';
3
3
  export class ModuleStyleWriter {
4
4
  config;
5
5
  packageContext;
@@ -24,8 +24,7 @@ export class ModuleStyleWriter {
24
24
  }
25
25
  }
26
26
  if (!root.nodes?.length) return null;
27
- fs.mkdirSync(path.dirname(target), { recursive: true });
28
- fs.writeFileSync(target, this.styleProcessor.stringify(root));
27
+ writeStyleFile(target, this.styleProcessor.stringify(root));
29
28
  return target;
30
29
  }
31
30
  }
@@ -3,8 +3,8 @@ import type {
3
3
  ModuleStyleBuildConfig,
4
4
  ResolvedModuleStyleBuildContext,
5
5
  } from '#auklet/types';
6
- export declare const emptyModuleEntryComment =
7
- '/* Empty style entry kept so automated tooling can resolve this module CSS path. */\n';
6
+ export declare const emptyStyleFileComment =
7
+ '/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
8
8
  export type FormatWriterOptions = {
9
9
  config: ModuleStyleBuildConfig;
10
10
  context: ResolvedModuleStyleBuildContext;
@@ -18,3 +18,4 @@ export declare function toRelativeImportSpecifier(
18
18
  fromDir: string,
19
19
  file: string,
20
20
  ): string;
21
+ export declare function writeStyleFile(file: string, code: string): void;
@@ -1,8 +1,13 @@
1
+ import fs from 'node:fs';
1
2
  import path from 'node:path';
2
3
  import { toPosixPath } from '#auklet/utils';
3
- export const emptyModuleEntryComment =
4
- '/* Empty style entry kept so automated tooling can resolve this module CSS path. */\n';
4
+ export const emptyStyleFileComment =
5
+ '/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
5
6
  export function toRelativeImportSpecifier(fromDir, file) {
6
7
  const relative = toPosixPath(path.relative(fromDir, file));
7
8
  return relative.startsWith('.') ? relative : `./${relative}`;
8
9
  }
10
+ export function writeStyleFile(file, code) {
11
+ fs.mkdirSync(path.dirname(file), { recursive: true });
12
+ fs.writeFileSync(file, code.trim() ? code : emptyStyleFileComment);
13
+ }
@@ -1,4 +1,4 @@
1
- import type { FormatWriterOptions } from '#auklet/css/production/format/shared';
1
+ import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
2
2
  export declare class SourceStyleFileWriter {
3
3
  private readonly sourceRoot;
4
4
  constructor(options: FormatWriterOptions);
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { writeStyleFile } from '#auklet/css/production/format/shared';
3
4
  export class SourceStyleFileWriter {
4
5
  sourceRoot;
5
6
  constructor(options) {
@@ -9,8 +10,7 @@ export class SourceStyleFileWriter {
9
10
  for (const sourceFile of files) {
10
11
  const relative = path.relative(this.sourceRoot, sourceFile);
11
12
  const target = path.join(outRoot, relative);
12
- fs.mkdirSync(path.dirname(target), { recursive: true });
13
- fs.copyFileSync(sourceFile, target);
13
+ writeStyleFile(target, fs.readFileSync(sourceFile, 'utf8'));
14
14
  }
15
15
  }
16
16
  }
@@ -2,7 +2,10 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { THEMES_DIR } from '#auklet/css/constants';
4
4
  import { createThemeEntryParts } from '#auklet/css/core/style/entries';
5
- import { toRelativeImportSpecifier } from '#auklet/css/production/format/shared';
5
+ import {
6
+ writeStyleFile,
7
+ toRelativeImportSpecifier,
8
+ } from '#auklet/css/production/format/shared';
6
9
  export class ThemeStyleWriter {
7
10
  config;
8
11
  packageContext;
@@ -36,8 +39,7 @@ export class ThemeStyleWriter {
36
39
  this.styleProcessor.appendStyleContent(root, content, stylePath);
37
40
  }
38
41
  const target = path.join(themesDir, `${themeName}.css`);
39
- fs.mkdirSync(path.dirname(target), { recursive: true });
40
- fs.writeFileSync(
42
+ writeStyleFile(
41
43
  target,
42
44
  root.nodes?.length ? this.styleProcessor.stringify(root) : '',
43
45
  );
@@ -71,8 +73,7 @@ export class ThemeStyleWriter {
71
73
  }
72
74
  }
73
75
  if (!root.nodes?.length) continue;
74
- fs.mkdirSync(targetDir, { recursive: true });
75
- fs.writeFileSync(target, this.styleProcessor.stringify(root));
76
+ writeStyleFile(target, this.styleProcessor.stringify(root));
76
77
  outputs.push(target);
77
78
  }
78
79
  return outputs;
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
2
+ import { writeStyleFile } from '#auklet/css/production/format/shared';
3
3
  import { getGlobalStyleDependencies } from '#auklet/css/core/style/dependencies';
4
4
  // Builds the package-level style entry at `dist/index.css` by aggregating local themes, dependencies, and source styles.
5
5
  export class PackageStyleEntryWriter {
@@ -41,12 +41,11 @@ export class PackageStyleEntryWriter {
41
41
  }
42
42
  }
43
43
  if (!root.nodes?.length) return null;
44
- fs.mkdirSync(this.outputRoot, { recursive: true });
45
44
  const target = path.join(
46
45
  this.outputRoot,
47
46
  this.config.output.indexStyleFile,
48
47
  );
49
- fs.writeFileSync(target, this.styleProcessor.stringify(root));
48
+ writeStyleFile(target, this.styleProcessor.stringify(root));
50
49
  return target;
51
50
  }
52
51
  get outputRoot() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
6
  "packageManager": "pnpm@10.27.0",