Skip to content

Commit 9345fce

Browse files
zompdkrizan
andauthored
feat: add branching (#195)
* chore: remove warning on every call There is `enable-pre-post-scripts` option which is set to true and is true by default, but it throws a warning, so I am removing it: npm warn Unknown project config "enable-pre-post-scripts". This will stop working in the next major version of npm. * docs: add left out preposition * feat: add --branch to push and pull commands * feat: add --branch to compare command * fix: update schema properly * fix: set branch param properly * test: branching in compare command * test: add branching to pull command * feat: add --branch to sync command * feat: add branch command * feat: add --branch to tag command * feat: add merge command * fix: use branch query param only when specified * fix: list only non-merged branches * chore: unify branch loading with platform * chore: enable branching feature & project setting * chore: replace `appendBranch` with `printBranchInfo` for improved branch logging consistency * chore: refine branch resolution logic and update merge command descriptions --------- Co-authored-by: Daniel Krizan <[email protected]>
1 parent 655a37f commit 9345fce

File tree

27 files changed

+6863
-3571
lines changed

27 files changed

+6863
-3571
lines changed

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
access=public
2-
enable-pre-post-scripts=true

HACKING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ These are the runnable scripts with `npm run`:
1414

1515
General:
1616

17-
- `run-dev`: Run the CLI (with [`tsx`](https://github.com/privatenumber/tsx)). Use `--` to pass arguments to the CLI rather than NPM: \
17+
- `run-dev`: Run the CLI (with [`tsx`](https://github.com/privatenumber/tsx)). Use `--` to pass arguments to the CLI rather than to NPM: \
1818
`npm run run-dev -- extract print --extractor react src/**/*.tsx`
1919
- `build`: Build the CLI.
2020
- `eslint`: Run ESLint.

schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"description": "Project ID. Only required when using a Personal Access Token.",
66
"type": ["number", "string"]
77
},
8+
"branch": {
9+
"description": "Project branch. Use when branching enabled for the project.",
10+
"type": "string",
11+
"minLength": 1
12+
},
813
"apiUrl": {
914
"description": "The url of Tolgee API.",
1015
"type": "string"

src/cli.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
STRICT_NAMESPACE,
2020
PARSER,
2121
PROJECT_ID_OPT,
22+
PROJECT_BRANCH,
2223
STRICT_NAMESPACE_NEGATION,
2324
VERBOSE,
2425
} from './options.js';
@@ -36,6 +37,8 @@ import ExtractCommand from './commands/extract.js';
3637
import CompareCommand from './commands/sync/compare.js';
3738
import SyncCommand from './commands/sync/sync.js';
3839
import TagCommand from './commands/tag.js';
40+
import BranchCommand from './commands/branch.js';
41+
import MergeCommand from './commands/merge.js';
3942

4043
import { getSingleOption } from './utils/getSingleOption.js';
4144
import { Schema } from './schema.js';
@@ -180,6 +183,7 @@ async function run() {
180183
program.addOption(API_URL_OPT.default(config.apiUrl ?? DEFAULT_API_URL));
181184
program.addOption(API_KEY_OPT.default(config.apiKey));
182185
program.addOption(PROJECT_ID_OPT.default(config.projectId ?? -1));
186+
program.addOption(PROJECT_BRANCH.default(config.branch));
183187
program.addOption(FORMAT_OPT.default(config.format ?? 'JSON_TOLGEE'));
184188
program.addOption(EXTRACTOR.default(config.extractor));
185189
program.addOption(FILE_PATTERNS.default(config.patterns));
@@ -209,6 +213,12 @@ async function run() {
209213
program.addCommand(
210214
TagCommand(config).configureHelp({ showGlobalOptions: true })
211215
);
216+
program.addCommand(
217+
BranchCommand(config).configureHelp({ showGlobalOptions: true })
218+
);
219+
program.addCommand(
220+
MergeCommand(config).configureHelp({ showGlobalOptions: true })
221+
);
212222

213223
await program.parseAsync();
214224
} catch (e: any) {

src/client/errorFromLoadable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export const errorFromLoadable = (loadable: LoadableData) => {
4343
loadable
4444
)}`;
4545

46+
// Not found (e.g. branch in project)
47+
case 404:
48+
return `Requested data not found. Please check your inputs ${addErrorDetails(loadable)}`;
49+
4650
// Rate limited
4751
case 429:
4852
return `You've been rate limited. Please try again later ${addErrorDetails(

0 commit comments

Comments
 (0)