Skip to content

Commit

Permalink
Update change all the tree method & prod easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasye24 committed May 8, 2023
1 parent ca864cc commit a74eacc
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
run: npm ci
- name: Run tests
run: npm test
- name: Build Package for Production
run: npm run build
publish-npm:
name: Publish to npm
needs: build
Expand Down
26 changes: 14 additions & 12 deletions short-long.js → Tools/Elisions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ by Tasye
*/


// Problematic:
// it's embarassing (in french, maybe other languages)
// when you see for example : "Le tailleur de André"
// ^^^
// in french you could write like this: "Le tailleur d'André"
// ---

/**
* @description With the prefix and the name(as *item*) return the appropriated prefix
* @author Tasye24
Expand All @@ -38,16 +30,17 @@ const take_long_or_short = (prefix, item) => {
* @param {string} pack name of the pack to import
*/
function pack_import(pack) {
let pack_path = "./pack/" + pack + ".json"
let pack_path = "../pack/" + pack + ".json"
let pack_json = require(pack_path);
//let pack_items = Object.keys(pack_json)
return pack_json
}

let version = require("../package.json")["version"]
let languages = ["fr-FR", "it-IT"]
let lang_packs = {}
languages.forEach((lang) => {
let a = require("./pack/"+[lang]+".json")
let a = require("../pack/"+[lang]+".json")
lang_packs[lang] = a // pack_import(lang);
})

Expand Down Expand Up @@ -101,5 +94,14 @@ const language = (item, with_pack, word, language) => {
language("Arbre", true, "le", "fr-FR") + "."
)*/

module.exports = take_long_or_short
module.exports = language

class Elisions {
constructor() {
this.elision = language;
this.info = {
"languages": languages
}
}
}

module.exports = Elisions
93 changes: 63 additions & 30 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
// Type definitions for Tasye-languages-tools v.0.0.3
// Project: Tasye Languages Tools
// Definitions by: @Tasye24 <[https://github.com/tasye24]>
/*~ This is the module template file. You should rename it to index.d.ts
*~ and place it in a folder with the same name as the module.
*~ For example, if you were writing a file for "super-greeter", this
*~ file should be 'super-greeter/index.d.ts'
*/
/*~ If this module is a UMD module that exposes a global variable 'myLib' when
*~ loaded outside a module loader environment, declare that global here.
*~ Otherwise, delete this declaration.
*/
export as namespace Tasye_Languages_Tools

export const tasye_current_version = "0.0.3"
export const ListOfLanguages:["fr-FR","it-IT"]

/**
* Function Language
* @example
* // With language_pack
* let sentence = "Le vélo " + language("Andrea", true, "de", "fr-FR")
* // > sentence = "Le vélo d'Andréa"
* @example
* // Without language_pack
* let word = {
* full: "de",
* short: "d'",
* }
* let sentence = "Le vélo " + language("Andrea", false, word)
* // > sentence = "Le vélo d'Andréa"
*/
export function language(item: string, with_pack:boolean, word: string, language?:string):string




// ======= Disabled
// ======= Refer using JsDOC in code
// ======= Seems this method is less efficient
// ======= For the moment


/*
export as namespace TasyeLanguageTools
export class TasyeLanguageTools {
constructor(lang?: string);
elision(): TLT.language
variables: {
language: string[]
version: string
}
}
declare namespace TLT {
/**
* @param {string} item the word for example a name like "Andrea"
* @param {boolean} with_pack use the pack ?
* @param {string?} language the language like "fr-FR"
* @param {string|object} word the word like "le"
* @type {(item: string, with_pack: boolean, word: string|{full: string, short: string, exeptions?: string}, language: string?) => string}
* @example
* // With language_pack
* let sentence = "Le vélo " + language("Andrea", true, "de", "fr-FR")
* // > sentence = "Le vélo d'Andréa"
* @example
* // Without language_pack
* let word = {
* full: "de",
* short: "d'",
* }
* let sentence = "Le vélo " + language("Andrea", false, word)
* // > sentence = "Le vélo d'Andréa"
* /
export interface language {
item: string
with_pack: boolean
language?: string
word: string|object
}
export interface variables {
/**
* SMTHIN
* @param language
* /
language: string[]
version: string
}
}
in comment like /* * / remove the last space thx if you want to use it
*/
29 changes: 29 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
TasyeLanguageTools
by Tasye - 2023
*/

const Elisions = require("./Tools/Elisions");
const Pkg = require("./package.json")

/*
class TLT extends Elisions {
constructor() {
super()
this.info["version"] = Pkg["version"]
this.info["author"] = Pkg["author"]
}
}*/

class TLT {
constructor() {
this.Elisions = new Elisions
this.__info__ = {
"author": Pkg["author"],
"version": Pkg["version"]
}
}
}

module.exports = TLT
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@tasye24/tasye-language-tools",
"version": "0.1.0-0",
"version": "0.1.1-0",
"author": "Tasye24 <[email protected]>",
"description": "## Intro In some languages like french (idk if others languages have same patterns) before a voyel and a muted \"*h*\" you should use an \"[*élision*](https://fr.wiktionary.org/wiki/%C3%A9lision)\".",
"main": "short-long.js",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/Tasye24/tasye-languages-tools.git"
Expand All @@ -12,7 +12,9 @@
"example": "examples"
},
"scripts": {
"test": "mocha \"**/*.test.js\""
"test": "mocha \"**/*.test.js\"",
"watch": "webpack --watch --env mode=development",
"build": "webpack --env mode=production"
},
"keywords": [
"javascript",
Expand All @@ -30,8 +32,7 @@
],
"license": "ISC",
"publishConfig": {
"registry": "https://npmjs.com/",
"@tasye24:registry": "https://npm.pkg.github.com"
"registry": "https://registry.npmjs.com/"
},
"bugs": {
"url": "https://github.com/Tasye24/tasye-languages-tools/issues"
Expand Down
6 changes: 0 additions & 6 deletions short-long.min.js

This file was deleted.

24 changes: 16 additions & 8 deletions tests/main.test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
const assert = require("assert")
const library = require("../short-long")
const library = require("../index.js")

let TLTools = new library
let language = TLTools.Elisions.elision

let tests = {
without_pack: [
{
actual: library("Andréa", 0,{full: "de",short: "d'"}),
actual: language("Andréa", 0,{full: "de",short: "d'"}),
expected: "d'Andréa"
}, {
actual: library("Bobby", 0,{full: "de",short: "d'"}),
actual: language("Bobby", 0,{full: "de",short: "d'"}),
expected: "de Bobby"
}
],
with_pack: [
{
actual: library("Andréa", 1, "de", "fr-FR"),
actual: language("Andréa", 1, "de", "fr-FR"),
expected: "d'Andréa"
}, {
actual: library("bus", 1, "le", "fr-FR"),
actual: language("bus", 1, "le", "fr-FR"),
expected: "le bus"
}, {
actual: library("autobus", 1, "lo", "it-IT"),
actual: language("autobus", 1, "lo", "it-IT"),
expected: "l'autobus"
}, {
actual: library("fratello", 1, "lo", "it-IT"),
actual: language("fratello", 1, "lo", "it-IT"),
expected: "lo fratello"
}
]
Expand Down Expand Up @@ -69,6 +72,11 @@ let Arrays_to_test = [
}
]

describe("Language() tester", ()=>{
console.log(`
Tasye Language Tools (v${TLTools.__info__["version"]})
List of Languages avaible: ${TLTools.Elisions.info.languages.join(", ")}
`)

describe("Elisions (Elision.elision) tester", ()=>{
Test_Master(Arrays_to_test)
})
39 changes: 28 additions & 11 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
const path = require('path');
const { env } = require('process');
const webpack = require('webpack');
/*const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');*/

module.exports = {
mode: "development",
entry: './short-long.js',
output: {
filename: 'bundle.dev.js',
path: path.resolve(__dirname, 'dist'),
library: "Language_Tools",
//libraryExport: "default",
libraryTarget: "this",
globalObject: "this"
},

module.exports = (env, argv) => {
let filename;
switch (env.mode) {
case "development":
filename = "dev"
break;
case "production":
filename = "prod";
break;
default:
filename = "testing"
break;
}

return {
mode: env.mode,
entry: './index.js',
output: {
filename: `bundle.${filename}.js`,
path: path.resolve(__dirname, 'dist'),
library: "Language_Tools",
//libraryExport: "default",
libraryTarget: "this",
globalObject: "this"
}
}
};

0 comments on commit a74eacc

Please sign in to comment.