Skip to content

Commit

Permalink
abjad-convert version 0.3.0 (#15)
Browse files Browse the repository at this point in the history
* new version 0.3.0

* refactor OnScreenKeyboard (#14)

## [0.3.0]  2024-01-17
### Added
- return array of letters of a script

* changes for yarn 4

* version next.2

* version next.3

* version next.4

* remove NODE_AUTH

* next.6

* use 0.3.0-next.6

* version 0.3.0-next.7
test publish in pipeline

* version 0.3.0
  • Loading branch information
amerharb authored Jan 17, 2024
1 parent c535eca commit 60c4d9a
Show file tree
Hide file tree
Showing 55 changed files with 897 additions and 745 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module.exports = {
plugins: [
'@typescript-eslint',
],
extends: [
'plugin:@next/next/recommended',
],
ignorePatterns: '*.js',
overrides: [
{
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
publish:
name: Publish to npm
name: Publish latest to npm
runs-on: ubuntu-latest
steps:
- name: fill package name
Expand All @@ -35,7 +35,7 @@ jobs:
- name: validate tag name
run: |
if [[ ! $TAG_NAME =~ ^$PACKAGE_NAME\/v([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)$ ]]; then
echo "❌ Invalid tag name: $TAG_NAME not suitable for latest release"
echo "❌ Invalid tag name: $TAG_NAME not suitable for @latest tag"
exit 1
else
echo "✅ Valid tag name: $TAG_NAME"
Expand All @@ -56,7 +56,7 @@ jobs:
echo "❌ Version in package.json of $PACKAGE_NAME: $PACKAGE_VERSION is not matching with tag name: $TAG_NAME"
exit 1
else
echo "✅ Version in package.json of $PACKAGE_NAME is matching with tag name"
echo "✅ Version: $PACKAGE_VERSION in package.json of $PACKAGE_NAME is matching with tag name: $TAG_NAME"
fi
- uses: actions/setup-node@v4
Expand All @@ -66,10 +66,10 @@ jobs:
always-auth: true
cache: yarn

- run: yarn workspace $PACKAGE_NAME install --frozen-lockfile
- run: yarn workspace $PACKAGE_NAME install --immutable

- name: publish abjad-convert @latest to npm
if: ${{ env.PACKAGE_NAME == 'abjad-convert' }}
run: yarn workspace abjad-convert publish --access public --no-git-tag-version --new-version $PACKAGE_VERSION --tag latest
run: yarn workspace abjad-convert npm publish --access public --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.ABJAD_CONVERT_PUBLISH_AUTH_TOKEN }}
8 changes: 5 additions & 3 deletions .github/workflows/publish-next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ jobs:
- name: validate tag name
run: |
if [[ ! $TAG_NAME =~ ^$PACKAGE_NAME\/v([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)-next\.([0-9]|[1-9][0-9]*)$ ]]; then
echo "❌ Invalid tag name: $TAG_NAME not suitable for next tag publish"
echo "❌ Invalid tag name: $TAG_NAME not suitable for @next tag"
exit 1
else
echo "✅ Valid tag name: $TAG_NAME"
fi
- name: validate version in package.json
run: |
if [[ ! $PACKAGE_VERSION =~ ^([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)-next\.([0-9]|[1-9][0-9]*)$ ]]; then
Expand All @@ -48,6 +49,7 @@ jobs:
else
echo "✅ Valid @next version: $PACKAGE_VERSION"
fi
- name: check if version in package.json is matching tag name
run: |
if [[ "$PACKAGE_NAME/v$PACKAGE_VERSION" != $TAG_NAME ]]; then
Expand All @@ -64,10 +66,10 @@ jobs:
always-auth: true
cache: yarn

- run: yarn workspace $PACKAGE_NAME install --frozen-lockfile
- run: yarn workspace $PACKAGE_NAME install --immutable

- name: publish abjad-convert @next to npm
if: ${{ env.PACKAGE_NAME == 'abjad-convert' }}
run: yarn workspace abjad-convert publish --access public --no-git-tag-version --new-version $PACKAGE_VERSION --tag next
run: yarn workspace abjad-convert npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.ABJAD_CONVERT_PUBLISH_AUTH_TOKEN }}
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs

enableTransparentWorkspaces: false

npmPublishRegistry: https://registry.npmjs.org
npmAuthToken: ${NODE_AUTH_TOKEN:-anyFallBackMockValue}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ This is a monorepo for the Abjad Convert project.

### Abjad Client
example of a client for the abjad convert package

### Abjad Web
[README](https://github.com/amerharb/abjad/blob/main/packages/abjad-web/README.md)
4 changes: 4 additions & 0 deletions packages/abjad-convert/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
<!-- https://keepachangelog.com/en/1.0.0/ -->

## [0.3.0] 2024-01-17
### Added
- return array of letters of a script

## [0.2.1] 2024-01-13
### Fixed
- badges in README.md
Expand Down
118 changes: 118 additions & 0 deletions packages/abjad-convert/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Abjad-convert Contributing

## Adding new script
Pull requests are welcome. For adding new script. let's say that we want to add a new script "Foo"
- Step #1: create a feature branch from `main` named `abjad-convert/version/0.[x].0` where `x` is the next minor of current version number.
- Step #2: create a new branch that will the previous feature branch when creating the PR.
- Step #3: create a new folder named `foo` in `src`.
- Step #4: add pdf documentation for the script we want to add from www.unicode.org. for example for Ugaritic the file is `U10380.pdf`. this file will be used as a reference
- Step #5: add a new file named `letters.ts` in `foo` folder this file will export
- - `letters` an array of letters written using unicode values with jsdoc each line will contain
the value of the letter using UTF-16 BE using escape \u followed by 4 hex digits.
notice that UTF16BE value is not always the same as the unicode value.
for example for letter Alpa in Ugaritic the unicode value is `0x10380` but the UTF16BE encode value is `0xD800DF80`
follow the value with jsdoc that contain array index, letter itself, unicode value, and the name of the letter.
for example for ugaritic looks like this:

```ts
const letters = [
'\uD800\uDF80', /** #0 𐎀 U+10380 UGARITIC LETTER ALPA */
'\uD800\uDF81', /** #1 𐎁 U+10381 UGARITIC LETTER BETA */
//...
];
```

- - 'Fo' an alias object called `Fo` short of Foo. this will give an alias for all letters mentioned in the letters array.

for example for ugaritic looks like this:
```ts
const Ug = {
Alpa: letters[0], // 𐎀
Beta: letters[1], // 𐎁
//...
};
```

- - `foo` an instance of `Script` class, which will be exported

for example for ugaritic looks like this:
```ts
export const ugaritic = new Script(
Abjad.Ugaritic, // enum value of the script
false, // true if the script is right to left
letters, // array of letters
Ug, // alias object of letters
)
```

- Step #6: Add the script to the enum `Abjad` in `src/types.ts` file.
at this point we have finished adding the script, but it is an island script. Meaning that it can't be converted to or from any other script.

- Step #7: To make it convertable we need at least to have one from and one to converter to another script.
the preferred way is to add a converter to and from Arabic script, as it is currently act as a de facto hub script for all abjad scripts.
The algorithm for converting will look first for 1-step converter (direct converter) the one that convert from the source to the target, in case there isn't any it will look for 2-steps approach where it can find a middle script,
after that it won't look for 3 or more steps, it will basically throw an error.
That is why Arabic is used as preferred hub, so if all script add converter to Arabic and Arabic add converter to all other scripts then all conversion is possible.
However, there is a plan in the future to add IPA to be a canonical hub script.

- - Adding to Arabic: Add file to `foo` folder with name `toArabic.ts` that include a class called FooToArabicConverter that implements `IConverter` interface.
it should look like this:
```ts
import { IConverter } from '../../types';
import { Fo } from './letters'
import { Ar } from '../arabic/letters'
import { IConverter } from '../../IConverter'
import { Abjad } from '../../types'

export class FooToArabicConverter implements IConverter {
public readonly from = Abjad.Foo
public readonly to = Abjad.Arabic
public convert(fooText: string): string {
// convert logic here
// return (araic text)
}
}
```
- - Add toArabic converter to `converterFactory.ts`
- - - import the new converter in alphabetical order
```ts
//...
import { FooToArabicConverter } from './foo/toArabic'
//...
```
- - - add the converter to converters array in alphabetical order
```ts
const converters: IConverter[] = [
//...
new TifinaghToArabicConverter(),
//...
];
```
- - Add toFoo converter to `arabic` folder with name `toFoo.ts` that include a class called ArabicToFooConverter that implements `IConverter` interface.
it should look like this:
```ts
import {Ar} from './letters'
import {Fo} from '../foo/letters'
import {IConverter} from '../../IConverter'
import {Abjad} from '../../types'

export class ArabicToFooConverter implements IConverter {
public readonly from = Abjad.Arabic
public readonly to = Abjad.Foo
public convert(arabicText: string): string {
// convert logic here
// return (foo text)
}
}
```
- - Add toFoo converter to `converterFactory.ts`

- Step #8 add unit test to`test/index.test.ts`.

- Step #9: update for new version
- - update `CHANGELOG.md` with the new version number and the changes.
- Step #10 update
- - `README.md` links and badges.
- - version in `package.json` file.
- - run yarn to update `yarn.lock` files
- - run test to update coverage badges
111 changes: 4 additions & 107 deletions packages/abjad-convert/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Abjad Convert
[![Version](https://img.shields.io/badge/version-0.2.1-blue.svg)](https://github.com/amerharb/abjad/tree/version/0.2.1)
[![Version](https://img.shields.io/badge/version-0.3.0-blue.svg)](https://github.com/amerharb/abjad/tree/version/0.3.0)
[![License: GPLv3](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
![Coverage](https://raw.githubusercontent.com/amerharb/abjad/abjad-convert/version/0.2.1/packages/abjad-convert/badges/coverage.svg)
![Github workflow](https://github.com/amerharb/abjad/actions/workflows/lint-test.yaml/badge.svg?branch=abjad-convert/version/0.2.1)
![Coverage](https://raw.githubusercontent.com/amerharb/abjad/abjad-convert/version/0.3.0/packages/abjad-convert/badges/coverage.svg)
![Github workflow](https://github.com/amerharb/abjad/actions/workflows/lint-test.yaml/badge.svg?branch=abjad-convert/version/0.3.0)

**abjad-convert** is a package for converting Abjad alphabets phonetically.

Expand All @@ -24,7 +24,7 @@ yarn:
yarn add abjad-convert
```

Java Script:
Type Script:
```js
import { convert, Abjad } from 'abjad-convert';

Expand All @@ -45,106 +45,3 @@ console.log(tifinaghWord); // ⵎⵔⵃⴱⴰ
const ugariticWord = convert(arabicWord, Abjad.Arabic, Abjad.Ugaritic);
console.log(ugariticWord); // 𐎎𐎗𐎈𐎁𐎀
```
## Contributing
### Adding new script
Pull requests are welcome. For adding new script. let's say that we want to add a new script "Foo"
- Step #1: create a feature branch from `main` named `abjad-convert/version/0.[x].0` where `x` is the next minor of current version number.
- Step #2: create a new branch that will the previous feature branch when creating the PR.
- Step #3: create a new folder named `foo` in `src`.
- Step #4: add pdf documentation for the script we want to add from www.unicode.org. for example for Ugaritic the file is `U10380.pdf`. this file will be used as a reference
- Step #5: add a new file named `letters.ts` in `foo` folder this file will export
- - `letters` an array of letters written using unicode values with jsdoc each line will contain
the value of the letter using UTF-16 BE using escape \u followed by 4 hex digits.
notice that UTF16BE value is not always the same as the unicode value.
for example for letter Alpa in Ugaritic the unicode value is `0x10380` but the UTF16BE encode value is `0xD800DF80`
follow the value with jsdoc that contain array index, letter itself, unicode value, and the name of the letter.
for example for ugaritic looks like this:

```ts
export const letters = [
'\uD800\uDF80', /** #0 𐎀 U+10380 UGARITIC LETTER ALPA */
'\uD800\uDF81', /** #1 𐎁 U+10381 UGARITIC LETTER BETA */
//...
];
```
- - 'Fo' an alias object called `Fo` short of Foo. this will give an alias for all letters mentioned in the letters array.

for example for ugaritic looks like this:
```ts
export const Ug = {
Alpa: letters[0], // 𐎀
Beta: letters[1], // 𐎁
//...
};
```

- Step #6: Add the script to the enum `Abjad` in `src/types.ts` file.
at this point we have finished adding the script, but it is an island script. Meaning that it can't be converted to or from any other script.

- Step #7: To make it convertable we need at least to have one from and one to converter to another script.
the preferred way is to add a converter to and from Arabic script, as it is currently act as a de facto hub script for all abjad scripts.
The algorithm for converting will look first for 1-step converter (direct converter) the one that convert from the source to the target, in case there isn't any it will look for 2-steps approach where it can find a middle script,
after that it won't look for 3 or more steps, it will basically throw an error.
That is why Arabic is used as preferred hub, so if all script add converter to Arabic and Arabic add converter to all other scripts then all conversion is possible.
However, there is a plan in the future to add IPA to be a canonical hub script.

- - Adding to Arabic: Add file to `foo` folder with name `toArabic.ts` that include a class called FooToArabicConverter that implements `IConverter` interface.
it should look like this:
```ts
import { IConverter } from '../types';
import { Fo } from './letters'
import { Ar } from '../arabic/letters'
import { IConverter } from '../IConverter'
import { Abjad } from '../types'

export class FooToArabicConverter implements IConverter {
public readonly from = Abjad.Foo
public readonly to = Abjad.Arabic
public convert(fooText: string): string {
// convert logic here
// return (araic text)
}
}
```
- - Add toArabic converter to `converterFactory.ts`
- - - import the new converter in alphabetical order
```ts
//...
import { FooToArabicConverter } from './foo/toArabic'
//...
```
- - - add the converter to converters array in alphabetical order
```ts
const converters: IConverter[] = [
//...
new TifinaghToArabicConverter(),
//...
];
```
- - Add toFoo converter to `arabic` folder with name `toFoo.ts` that include a class called ArabicToFooConverter that implements `IConverter` interface.
it should look like this:
```ts
import {Ar} from './letters'
import {Fo} from '../foo/letters'
import {IConverter} from '../IConverter'
import {Abjad} from '../types'

export class ArabicToFooConverter implements IConverter {
public readonly from = Abjad.Arabic
public readonly to = Abjad.Foo
public convert(arabicText: string): string {
// convert logic here
// return (foo text)
}
}
```
- - Add toFoo converter to `converterFactory.ts`

- Step #8 add unit test to`test/index.test.ts`.

- Step #9: update for new version
- - update `CHANGELOG.md` with the new version number and the changes.
- - Step #10 update `README.md` links and badges.
- - Update version in `package.json` file.
- - run yarn to update yarn.lock files
- - run test to update coverage badges
2 changes: 1 addition & 1 deletion packages/abjad-convert/badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/abjad-convert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abjad-convert",
"version": "0.2.1-disable.local",
"version": "0.3.0",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"files": [
Expand Down
Loading

0 comments on commit 60c4d9a

Please sign in to comment.