Skip to content

Commit

Permalink
fix: tsdk sync files should include JSON files too
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Jan 20, 2024
1 parent 734df89 commit 5afac09
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This is the log of notable changes to the `tsdk` that are developer-facing.


### 0.1.3 2024/01/20

- Fix: sync shared files should include JSON files like `*.json` or `*.shared.json`

### 0.1.2 2024/01/20

- Chore: add `incremental: true` in fe-sdk template's tsconfig.json
Expand Down
3 changes: 2 additions & 1 deletion examples/server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ build-*
*.db
*.db-shm
*.db-wal
*.sqlite
*.sqlite
packages/fe-sdk-demo
3 changes: 3 additions & 0 deletions examples/server/src/i18n/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "hello world"
}
6 changes: 3 additions & 3 deletions examples/server/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'intl-pluralrules';
import i18next from 'i18next';

const translation = {
hello: 'hello world',
};
import helloJSON from './index.json';

const translation = helloJSON;
export const i18n = i18next.createInstance(
{
fallbackLng: 'en',
Expand Down
3 changes: 3 additions & 0 deletions examples/server/src/test-shared/index.shared.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "hello world"
}
3 changes: 3 additions & 0 deletions examples/server/src/test-shared/index.shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import helloJSON from './index.shared.json';

export { helloJSON };
1 change: 1 addition & 0 deletions examples/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"target": "es2017",
"sourceMap": true,
"baseUrl": "./",
Expand Down
2 changes: 1 addition & 1 deletion packages/tsdk-server-adapters/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk-server-adapters",
"version": "0.1.2",
"version": "0.1.3",
"main": "lib/index.js",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/tsdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk",
"version": "0.1.2",
"version": "0.1.3",
"description": "Type-safe API development and code share tool for TypeScript projects.",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down
6 changes: 3 additions & 3 deletions packages/tsdk/src/sync-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export async function syncSharedFiles() {
console.log(symbols.bullet, `sync shared files`);

const files = await glob([
...config.sharedDirs.map((i) => path.join(i, `**/*.ts`).replace(/\\/g, '/')),
path.join(config.baseDir, `**/*.${config.shareExt || 'shared'}.ts`),
...config.sharedDirs.map((i) => path.join(i, `**/*.*`).replace(/\\/g, '/')),
path.join(config.baseDir, `**/*.${config.shareExt || 'shared'}.*`),
]);
files.sort();

Expand All @@ -248,7 +248,7 @@ export async function syncSharedFiles() {
);
fromPath = path.normalize(fromPath);
fromPath = fromPath.startsWith('.') ? fromPath : './' + fromPath;
if (fromPath.indexOf('tsdk-types') < 0) {
if (fromPath.indexOf('tsdk-types') < 0 && filePath.endsWith('.ts')) {
indexContentMap[file] = `export * from '${fromPath.replace(/\\/g, '/')}';\n`;
}
return fsExtra.writeFile(filePath, content);
Expand Down

0 comments on commit 5afac09

Please sign in to comment.