Skip to content

Commit

Permalink
Merge pull request #18 from yoloforks/setup-monorepository
Browse files Browse the repository at this point in the history
  • Loading branch information
Pisyukaev authored Nov 21, 2023
2 parents e17bec4 + 027ec1a commit e39bfa7
Show file tree
Hide file tree
Showing 43 changed files with 2,690 additions and 697 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
12 changes: 12 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "minor",
"bumpVersionsWithWorkspaceProtocolOnly": true,
"ignore": []
}
54 changes: 54 additions & 0 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: NPM Publish

on:
push:
branches:
- master

permissions:
id-token: write

jobs:
cache-and-install:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm build

- name: Publish packages
shell: bash
run: |
echo "//registry.npmjs.org/:_authToken="${{ secrets.NPM_TOKEN }}"" > ~/.npmrc
pnpm -r --filter='./packages/*' publish --access public --provenance
41 changes: 0 additions & 41 deletions .github/workflows/test.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
.vscode
.turbo
coverage
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
provenance=true
auto-install-peers=true
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
coverage
.turbo
.github
.vscode
.changeset
*.log*
*.log
*.yaml
*.yml
*.md
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.preferences.importModuleSpecifierEnding": "js"
}
60 changes: 22 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
{
"name": "xml-locales",
"version": "1.0.0",
"name": "xml-locales-workspaces",
"version": "0.0.0",
"private": true,
"description": "Tool for locales in xml files",
"main": "src/index.js",
"bin": {
"xml-locales": "src/index.js"
},
"workspaces": [
"packages/*"
],
"scripts": {
"start": "pnpm build && node dist/bin.mjs --help",
"dev": "tsup --watch",
"build": "tsup",
"type-check": "tsc --noEmit",
"dev": "turbo run dev --filter=./packages/*",
"build": "turbo run build --filter=./packages/*",
"test": "pnpm build && vitest run --coverage",
"test:watch": "vitest --ui --watch --coverage",
"format": "prettier --write **/*.{js,ts,tsx,json}",
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run"
"changeset": "changeset"
},
"keywords": [
"xml-locales",
"xml",
"locales",
"tool",
"cli-tool"
],
"author": "",
"license": "ISC",
"devDependencies": {
"@pisyukaev/prettier-config": "^3.2.1",
"@pisyukaev/tsconfig": "^2.0.1",
"@types/node": "^20.4.2",
"nodemon": "^3.0.1",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"vitest": "^0.34.3"
},
"dependencies": {
"@inquirer/prompts": "^3.0.2",
"@types/yargs": "^17.0.24",
"fast-xml-parser": "^4.2.7",
"xml-formatter": "^3.5.0",
"yargs": "^17.7.2"
"@changesets/cli": "2.26.2",
"@pisyukaev/prettier-config": "3.3.2",
"@pisyukaev/tsconfig": "2.0.1",
"@types/node": "20.9.3",
"@vitest/coverage-v8": "0.34.6",
"@vitest/ui": "0.34.6",
"tsup": "8.0.1",
"turbo": "1.10.16",
"typescript": "5.3.2",
"vite": "5.0.0",
"vitest": "0.34.6"
}
}
26 changes: 26 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@xml-locales/cli",
"version": "0.0.0",
"type": "module",
"bin": {
"xml-locales": "./dist/index.js"
},
"keywords": [
"xml-locales",
"xml",
"locales",
"tool",
"cli-tool"
],
"scripts": {
"build": "tsc",
"test": "vitest run --coverage",
"test:watch": "vitest --ui --watch --coverage"
},
"dependencies": {
"@inquirer/prompts": "3.3.0",
"@types/yargs": "17.0.32",
"xml-locales": "workspace:0.0.0",
"yargs": "17.7.2"
}
}
2 changes: 1 addition & 1 deletion src/index.ts → packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import { commands } from './commands';
import { commands } from './commands/index.js';

yargs(hideBin(process.argv))
.scriptName('xml-locales')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { add } from 'xml-locales';
import { modificationFile } from 'xml-locales/utils';
import type { ArgumentsCamelCase, Argv } from 'yargs';

import { add } from '../modifiers/add';
import { modificationFile } from '../utils/files';

export const command = 'add';
export const description = 'Add one localization string in files';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { change } from 'xml-locales';
import { modificationFile } from 'xml-locales/utils';
import type { ArgumentsCamelCase, Argv } from 'yargs';

import { change } from '../modifiers/change';
import { modificationFile } from '../utils/files';

export const command = 'change';
export const description = 'Change key or value of localization string';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { del } from 'xml-locales';
import { modificationFile } from 'xml-locales/utils';
import type { ArgumentsCamelCase, Argv } from 'yargs';

import { del } from '../modifiers/delete';
import { modificationFile } from '../utils/files';

export const command = 'delete';
export const description = 'Delete one localization string in files';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'node:fs/promises';
import type { ArgumentsCamelCase, Argv } from 'yargs';

import { newLocale } from '../modifiers/newLocale';

export const command = 'new';
export const description = 'Create new localization file from master file';

Expand Down Expand Up @@ -29,5 +28,16 @@ export async function handler({
name: string;
master: string;
}>) {
newLocale({ name, master });
await newLocale({ name, master });
}

async function newLocale(options: { name: string; master: string }) {
const { name, master } = options;

try {
await fs.copyFile(master, name);
console.log(`${master} was copied to ${name}`);
} catch (err) {
console.error(err);
}
}
5 changes: 2 additions & 3 deletions src/commands/sort.ts → packages/cli/src/commands/sort.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { sort } from 'xml-locales';
import { modificationFile } from 'xml-locales/utils';
import type { ArgumentsCamelCase, Argv } from 'yargs';

import { sort } from '../modifiers/sort';
import { modificationFile } from '../utils/files';

export const command = 'sort';
export const description = 'Sorted keys of strings by asc or desc';

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/cli/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineProject } from 'vitest/config';

export default defineProject({
test: {
name: 'cli',
environment: 'node'
}
});
33 changes: 33 additions & 0 deletions packages/xml-locales/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "xml-locales",
"description": "Tool for locales in xml files",
"version": "0.0.0",
"type": "module",
"keywords": [
"xml-locales",
"xml",
"locales"
],
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"utils": [
"./dist/utils/index.d.ts"
]
}
},
"exports": {
".": "./dist/index.js",
"./utils": "./dist/utils/index.js"
},
"scripts": {
"dev": "tsup --watch",
"build": "tsup",
"test": "vitest run --coverage",
"test:watch": "vitest --ui --watch --coverage"
},
"dependencies": {
"fast-xml-parser": "4.3.2",
"xml-formatter": "3.6.0"
}
}
4 changes: 4 additions & 0 deletions packages/xml-locales/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './modifiers/sort.js';
export * from './modifiers/add.js';
export * from './modifiers/change.js';
export * from './modifiers/delete.js';
Loading

0 comments on commit e39bfa7

Please sign in to comment.