Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
82778fc
feat(cli): add replexica init command
maxprilutskiy May 1, 2024
c57d920
chore: moved classic demo dir to /demo
maxprilutskiy May 1, 2024
068a6f0
chore: upd lockfile
maxprilutskiy May 1, 2024
5bb7292
feat(cli): add `projects` to i18n.json
maxprilutskiy May 1, 2024
ab09066
feat(spec): added `@replexica/spec` package
maxprilutskiy May 1, 2024
1ffb1b4
chore(spec): migrate compiler + cli to use spec
maxprilutskiy May 1, 2024
76112c2
refactor(spec): refactored i18n.json format
maxprilutskiy May 1, 2024
bbc8365
refactor: upd
maxprilutskiy May 1, 2024
c8150da
chore: upd i18n.json
maxprilutskiy May 2, 2024
f554250
feat: add translator fn implementation
maxprilutskiy May 2, 2024
9b22072
feat: add replexica bucket processor
maxprilutskiy May 2, 2024
99da1ae
feat: implement replexica bucket processor
maxprilutskiy May 2, 2024
d008d41
refactor: refactoring
maxprilutskiy May 2, 2024
de8693a
refactor: refactoring
maxprilutskiy May 2, 2024
15c2e6e
feat: add markdown bucket processor
maxprilutskiy May 2, 2024
e334109
feat: add bucket processors
maxprilutskiy May 2, 2024
9add3c4
refactor: remove old cli code
maxprilutskiy May 2, 2024
61ecd1d
chore: cleanup
maxprilutskiy May 2, 2024
cc3094b
feat(spec): add add config / formats to @replexica/spec
maxprilutskiy May 2, 2024
87deb92
feat(cli): add `replexica config` cli command
maxprilutskiy May 2, 2024
b4e1797
feat(cli): fallback to using default config instead of throwing an error
maxprilutskiy May 2, 2024
d6d9bd4
feat(compiler): use config merging in compiler
maxprilutskiy May 2, 2024
138a9e1
feat: migrate to the new compiler / config
maxprilutskiy May 2, 2024
fb95d40
docs(spec): changeset for `@replexica/spec`
maxprilutskiy May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-squids-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@replexica/spec": minor
---

intro a `@replexica/spec` package containing common definitions, constants, schemas, and types
17 changes: 17 additions & 0 deletions demo/classic/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"locale": {
"source": "en",
"targets": [
"es"
]
},
"buckets": {
"": "replexica",
"json/[locale].json": "json",
"xcode/Localizable.xcstrings": "xcode",
"yaml/[locale].yml": "yaml",
"yaml-root-key/[locale].yml": "yaml-root-key",
"markdown/[locale].md": "markdown"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions demo/classic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@replexica/demo/classic",
"private": true,
"version": "0.0.0",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"replexica": "workspace:*"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 2 additions & 14 deletions demo/next-app-shadcnui/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import compiler from '@replexica/compiler';
import replexica from '@replexica/compiler';

/** @type {import('next').NextConfig} */
const nextConfig = {};

/** @type {import('@replexica/compiler').ReplexicaConfig} */
const replexicaConfig = {
locale: {
source: 'en',
targets: ['es'],
},
debug: true,
};

export default compiler.next(
replexicaConfig,
nextConfig,
);
export default replexica.next()(nextConfig);
12 changes: 12 additions & 0 deletions demo/next-app/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"locale": {
"source": "en",
"targets": [
"es"
]
},
"buckets": {
"": "replexica"
}
}
16 changes: 2 additions & 14 deletions demo/next-app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import compiler from '@replexica/compiler';
import replexica from '@replexica/compiler';

/** @type {import('next').NextConfig} */
const nextConfig = {};

/** @type {import('@replexica/compiler').ReplexicaConfig} */
const replexicaConfig = {
locale: {
source: 'en',
targets: ['es'],
},
debug: true,
};

export default compiler.next(
replexicaConfig,
nextConfig,
);
export default replexica.next()(nextConfig);
29 changes: 0 additions & 29 deletions demo/node/CHANGELOG.md

This file was deleted.

9 changes: 0 additions & 9 deletions demo/node/index.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions demo/node/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions demo/node/index.mjs

This file was deleted.

17 changes: 0 additions & 17 deletions demo/node/package.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
"dependencies": {
"@inquirer/prompts": "^4.3.1",
"@paralleldrive/cuid2": "^2.2.2",
"@replexica/spec": "workspace:*",
"commander": "^12.0.0",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"flat": "^6.0.1",
"ini": "^4.1.2",
"lodash": "^4.17.21",
"object-hash": "^3.0.0",
"open": "^10.1.0",
"ora": "^8.0.1",
"typescript": "^5.4.5",
Expand All @@ -44,6 +46,7 @@
"@types/express": "^4.17.21",
"@types/ini": "^4.1.0",
"@types/lodash": "^4.17.0",
"@types/node": "^20"
"@types/node": "^20",
"@types/object-hash": "^3.0.6"
}
}
37 changes: 20 additions & 17 deletions packages/cli/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import express from 'express';
import cors from 'cors';
import open from 'open';
import readline from 'readline/promises';
import { loadSettings } from "./services/settings.js";
import { getEnv } from "./services/env.js";
import { checkAuth } from "./services/check-auth.js";
import { saveApiKey } from "./services/api-key.js";
import { loadSettings, saveSettings } from "./services/settings.js";
import { loadAuth } from "./services/auth.js";

export default new Command()
.command("auth")
Expand All @@ -17,30 +15,34 @@ export default new Command()
.option("--login", "Authenticate with Replexica API")
.action(async (options) => {
try {
const env = getEnv();
let config = await loadSettings();
let settings = await loadSettings();

if (options.logout) {
await logout();
settings.auth.apiKey = null;
await saveSettings(settings);
}
if (options.login) {
await login(env.REPLEXICA_WEB_URL);
config = await loadSettings();
const apiKey = await login(settings.auth.apiUrl);
settings.auth.apiKey = apiKey;
await saveSettings(settings);
settings = await loadSettings();
}

await checkAuth();
const auth = await loadAuth({
apiUrl: settings.auth.apiUrl,
apiKey: settings.auth.apiKey!,
});
if (!auth) {
Ora().warn('Not authenticated');
} else {
Ora().succeed(`Authenticated as ${auth.email}`);
}
} catch (error: any) {
Ora().fail(error.message);
process.exit(1);
}
});

async function logout() {
const spinner = Ora().start('Logging out');
await saveApiKey(null);
spinner.succeed('Logged out');
}

async function login(apiUrl: string) {
await readline.createInterface({
input: process.stdin,
Expand All @@ -52,7 +54,8 @@ async function login(apiUrl: string) {
await open(`${apiUrl}/app/cli?port=${port}`, { wait: false });
});
spinner.succeed('API key received');
await saveApiKey(apiKey);

return apiKey;
}

async function waitForApiKey(cb: (port: string) => void): Promise<string> {
Expand Down
30 changes: 30 additions & 0 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Command } from "commander";
import _ from "lodash";
import fs from 'fs';
import path from 'path';
import { defaultConfig } from "@replexica/spec";

export default new Command()
.command("config")
.description("Prints out the current configuration")
.helpOption("-h, --help", "Show help")
.action(async (options) => {
const fileConfig = loadReplexicaFileConfig();
const config = _.merge(
{},
defaultConfig,
fileConfig,
);

console.log(JSON.stringify(config, null, 2));
});

function loadReplexicaFileConfig(): any {
const replexicaConfigPath = path.resolve(process.cwd(), 'i18n.json');
const fileExists = fs.existsSync(replexicaConfigPath);
if (!fileExists) { return undefined; }

const fileContent = fs.readFileSync(replexicaConfigPath, 'utf-8');
const replexicaFileConfig = JSON.parse(fileContent);
return replexicaFileConfig;
}
Loading