Skip to content

Commit 2699ec1

Browse files
authored
Fixed local dolphin.y[a]ml not automatically detected issue (#23)
Resolved #22
1 parent 5827179 commit 2699ec1

File tree

6 files changed

+9
-22
lines changed

6 files changed

+9
-22
lines changed

.changeset/sour-trainers-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rootapp/dolphin': patch
3+
---
4+
5+
Fixed local dolphin.y[a]ml not automatically detected issue

apps/cli/src/commands/import.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Arguments, ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
66
import { importLocalizations, loadConfig } from './core.js';
77

88
interface CmdArgs extends Arguments {
9-
config: string;
9+
config?: string;
1010
bundlePath: string;
1111
}
1212

@@ -21,7 +21,6 @@ const cmd: CommandModule<{}, CmdArgs> = {
2121
describe:
2222
'Path to the config file. Will search dolphin.y[a]ml under root path if not specified',
2323
type: 'string',
24-
demandOption: true,
2524
},
2625
bundlePath: {
2726
alias: 'p',
@@ -50,10 +49,6 @@ async function handleImportCommand(args: CmdArgs) {
5049
logger.info('===================================');
5150
logger.info('============= Importing ===========');
5251
logger.info('===================================');
53-
if (!args.config) {
54-
spinner.fail(chalk.red('Config file path is not specified'));
55-
return;
56-
}
5752
const config = await loadConfig({
5853
path: args.config,
5954
});

packages/base/src/__tests__/config.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import { describe, expect, it } from 'vitest';
66
import { LocalizationFormat, parseConfig, parseConfigText } from '../config';
77

88
describe('Config Parser', () => {
9-
it('should throw error when no config path provided', async () => {
10-
await expect(parseConfig(undefined)).rejects.toThrow('Missing config file');
11-
});
12-
139
it('should throw error for invalid config path', async () => {
1410
await expect(
1511
parseConfig('/some-invalid/path/config.yml'),

packages/base/src/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,7 @@ export async function parseConfigText({
127127
}
128128

129129
export async function parseConfig(userConfigPath?: string): Promise<Config> {
130-
let configPath = userConfigPath;
131-
if (!configPath) {
132-
throw new Error(
133-
`Missing config file. You can either set using --config or put dolphin.y[a]ml under the root path of the project.`,
134-
);
135-
}
136-
configPath = absoluteFilePath(configPath, process.cwd());
130+
let configPath = absoluteFilePath(userConfigPath ?? '', process.cwd());
137131
// Check if configPath is a directory
138132
const stats = await fs.promises.stat(configPath);
139133
if (stats.isDirectory()) {

packages/translate/src/__tests__/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,6 @@ describe('mergeDolphinJsons', () => {
228228
});
229229

230230
mergeDolphinJsons({ newJson, previousJson });
231-
expect(newJson.strings.key1.localizations.ja.state).toBe('translated');
231+
expect(newJson.strings.key1.localizations.ja.state).toBe('new');
232232
});
233233
});

packages/translate/src/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,7 @@ function getState({
189189
);
190190
if (isSourceDifferent) {
191191
// if source changes, we consider it as new
192-
if (newTargetUnit.state === 'undefined') {
193-
return 'new';
194-
}
195-
return newTargetUnit.state;
192+
return 'new';
196193
}
197194
const isTargetDifferent = newTargetUnit.value !== previousTargetUnit.value;
198195
if (isTargetDifferent) {

0 commit comments

Comments
 (0)