@saykit/config 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  > Configuration schema and CLI for [SayKit](https://saykit.js.org).
4
4
 
5
+ [![Coverage](https://codecov.io/gh/k0d13/saykit/graph/badge.svg?flag=config)](https://codecov.io/gh/k0d13/saykit?flags%5B0%5D=config)
6
+
5
7
  Provides the `defineConfig` helper, the Zod-validated schema for `saykit.config.ts`, and the `saykit` CLI used to extract messages from your source.
6
8
 
7
9
  ## Install
@@ -102,15 +102,11 @@ function reconcileLocaleMessages(existingMessages, nextMessages) {
102
102
  function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
103
103
  return (0, node_path.resolve)(bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1)));
104
104
  }
105
- function expandBucketOutputIgnoreDirectory(bucket) {
106
- const [prefix] = bucket.output.split("{locale}");
107
- return (0, node_path.resolve)(prefix || ".");
108
- }
109
105
  //#endregion
110
106
  //#region src/features/catalogue/storage.ts
111
107
  const DECLARATION_CONTENT = `
112
- declare const translations: Record<string, string>;
113
- export default translations;
108
+ declare const messages: Record<string, string>;
109
+ export default messages;
114
110
  `.trim();
115
111
  async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
116
112
  const content = await (0, node_fs_promises.readFile)(path, "utf8").catch(() => "");
@@ -124,16 +120,8 @@ async function writeCatalogueMessages(bucket, locale, messages, path = expandBuc
124
120
  existingContent
125
121
  });
126
122
  const declarationPath = `${path}.d.ts`;
127
- const ignoreDirectory = expandBucketOutputIgnoreDirectory(bucket);
128
- const ignorePath = (0, node_path.join)(ignoreDirectory, ".gitignore");
129
- const ignoreContent = `.gitignore\n*.${bucket.formatter.extension.slice(1)}.d.ts`;
130
123
  await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
131
- await (0, node_fs_promises.mkdir)(ignoreDirectory, { recursive: true });
132
- await Promise.all([
133
- (0, node_fs_promises.writeFile)(path, catalogueContent),
134
- (0, node_fs_promises.writeFile)(declarationPath, DECLARATION_CONTENT),
135
- (0, node_fs_promises.writeFile)(ignorePath, ignoreContent)
136
- ]);
124
+ await Promise.all([(0, node_fs_promises.writeFile)(path, catalogueContent), (0, node_fs_promises.writeFile)(declarationPath, DECLARATION_CONTENT)]);
137
125
  }
138
126
  //#endregion
139
127
  //#region src/features/watch.ts
@@ -101,15 +101,11 @@ function reconcileLocaleMessages(existingMessages, nextMessages) {
101
101
  function expandBucketOutputPath(bucket, locale, extension = bucket.formatter.extension) {
102
102
  return resolve(bucket.output.replaceAll("{locale}", locale).replaceAll("{extension}", extension.slice(1)));
103
103
  }
104
- function expandBucketOutputIgnoreDirectory(bucket) {
105
- const [prefix] = bucket.output.split("{locale}");
106
- return resolve(prefix || ".");
107
- }
108
104
  //#endregion
109
105
  //#region src/features/catalogue/storage.ts
110
106
  const DECLARATION_CONTENT = `
111
- declare const translations: Record<string, string>;
112
- export default translations;
107
+ declare const messages: Record<string, string>;
108
+ export default messages;
113
109
  `.trim();
114
110
  async function readCatalogueMessages(bucket, locale, path = expandBucketOutputPath(bucket, locale)) {
115
111
  const content = await readFile(path, "utf8").catch(() => "");
@@ -123,16 +119,8 @@ async function writeCatalogueMessages(bucket, locale, messages, path = expandBuc
123
119
  existingContent
124
120
  });
125
121
  const declarationPath = `${path}.d.ts`;
126
- const ignoreDirectory = expandBucketOutputIgnoreDirectory(bucket);
127
- const ignorePath = join(ignoreDirectory, ".gitignore");
128
- const ignoreContent = `.gitignore\n*.${bucket.formatter.extension.slice(1)}.d.ts`;
129
122
  await mkdir(dirname(path), { recursive: true });
130
- await mkdir(ignoreDirectory, { recursive: true });
131
- await Promise.all([
132
- writeFile(path, catalogueContent),
133
- writeFile(declarationPath, DECLARATION_CONTENT),
134
- writeFile(ignorePath, ignoreContent)
135
- ]);
123
+ await Promise.all([writeFile(path, catalogueContent), writeFile(declarationPath, DECLARATION_CONTENT)]);
136
124
  }
137
125
  //#endregion
138
126
  //#region src/features/watch.ts
@@ -54,13 +54,14 @@ var ChoiceMessage = class extends Base {
54
54
  }
55
55
  };
56
56
  var CompositeMessage = class extends Base {
57
- constructor(descriptor, comments, references, children, accessor) {
57
+ constructor(descriptor, comments, references, children, accessor, whitespace) {
58
58
  super();
59
59
  this.descriptor = descriptor;
60
60
  this.comments = comments;
61
61
  this.references = references;
62
62
  this.children = children;
63
63
  this.accessor = accessor;
64
+ this.whitespace = whitespace;
64
65
  }
65
66
  };
66
67
  //#endregion
@@ -46,10 +46,11 @@ declare class CompositeMessage extends Base {
46
46
  readonly references: string[];
47
47
  readonly children: Message[];
48
48
  readonly accessor: any;
49
+ readonly whitespace?: boolean | undefined;
49
50
  constructor(descriptor: {
50
51
  id?: string;
51
52
  context?: string;
52
- }, comments: string[], references: string[], children: Message[], accessor: any);
53
+ }, comments: string[], references: string[], children: Message[], accessor: any, whitespace?: boolean | undefined);
53
54
  }
54
55
  type Message = LiteralMessage | ArgumentMessage | ElementMessage | ChoiceMessage | CompositeMessage;
55
56
  //#endregion
@@ -46,10 +46,11 @@ declare class CompositeMessage extends Base {
46
46
  readonly references: string[];
47
47
  readonly children: Message[];
48
48
  readonly accessor: any;
49
+ readonly whitespace?: boolean | undefined;
49
50
  constructor(descriptor: {
50
51
  id?: string;
51
52
  context?: string;
52
- }, comments: string[], references: string[], children: Message[], accessor: any);
53
+ }, comments: string[], references: string[], children: Message[], accessor: any, whitespace?: boolean | undefined);
53
54
  }
54
55
  type Message = LiteralMessage | ArgumentMessage | ElementMessage | ChoiceMessage | CompositeMessage;
55
56
  //#endregion
@@ -53,13 +53,14 @@ var ChoiceMessage = class extends Base {
53
53
  }
54
54
  };
55
55
  var CompositeMessage = class extends Base {
56
- constructor(descriptor, comments, references, children, accessor) {
56
+ constructor(descriptor, comments, references, children, accessor, whitespace) {
57
57
  super();
58
58
  this.descriptor = descriptor;
59
59
  this.comments = comments;
60
60
  this.references = references;
61
61
  this.children = children;
62
62
  this.accessor = accessor;
63
+ this.whitespace = whitespace;
63
64
  }
64
65
  };
65
66
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saykit/config",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CLI and configuration tooling for saykit",
5
5
  "keywords": [
6
6
  "cli",
@@ -66,7 +66,7 @@
66
66
  "@commander-js/extra-typings": "^14.0.0",
67
67
  "commander": "^14.0.3",
68
68
  "js-sha256": "^0.11.1",
69
- "picomatch": "^4.0.4",
69
+ "picomatch": "^4.0.5",
70
70
  "zod": "^4.4.3"
71
71
  },
72
72
  "devDependencies": {
@@ -82,8 +82,6 @@
82
82
  },
83
83
  "scripts": {
84
84
  "check": "tsc --noEmit",
85
- "test": "vitest",
86
- "coverage": "vitest run --coverage",
87
85
  "build": "tsdown"
88
86
  }
89
87
  }