@next-box/i18n 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@next-box/i18n",
3
3
  "description": "A type-safe content resolver with content path auto-complete and value preview.",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "author": "miami-man",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/next-box",
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
- export * from './components/I18nProvider.tsx';
2
- export * from './components/Md.tsx';
3
1
  export * from './main.ts';
4
2
  export * from './types.ts';
@@ -3,7 +3,7 @@ import { md } from '#macros.ts';
3
3
  describe('md', () => {
4
4
  describe('when a valid path is provided', () => {
5
5
  it('should return the markdown content in the file the path resolves to', () => {
6
- const content = md('./packages/i18n/src/__testUtils__/content.md');
6
+ const content = md('./__testUtils__/content.md');
7
7
 
8
8
  expect(content).toMatchInlineSnapshot(`
9
9
  "# Page title
@@ -23,13 +23,13 @@ describe('md', () => {
23
23
 
24
24
  describe('when no path is not provided', () => {
25
25
  it('should throw the expected error', () => {
26
- expect(() => md('')).toThrow('Tagged template expected a path, but received none');
26
+ expect(() => md('')).toThrow('md expected a path, but received none');
27
27
  });
28
28
  });
29
29
 
30
30
  describe('when a valid path is not provided', () => {
31
31
  it('should throw the expected error', () => {
32
- expect(() => md('./packages/i18n/src/__testUtils__/no-content.md')).toThrow();
32
+ expect(() => md('./__testUtils__/no-content.md')).toThrow();
33
33
  });
34
34
  });
35
35
  });
package/src/macros.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { resolve } from 'node:path';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const dir = dirname(fileURLToPath(import.meta.url));
3
6
 
4
7
  export const md = <P extends string>(path: P): P => {
5
8
  if (!path) {
6
- throw new Error('Tagged template expected a path, but received none');
9
+ throw new Error('md expected a path, but received none');
7
10
  }
8
11
 
9
- const fullPath = resolve(process.cwd(), path);
12
+ const fullPath = resolve(dir, path);
10
13
  // @ts-expect-error `md` function runs and build time and its return value
11
14
  // replaces the `md` invocation. We are forcing the return type to be the
12
15
  // input type to aid type inference when using `createI18n` and its