ipa-core 1.1.13 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/fill-orthography.js +57 -0
- package/generate-config.js +15 -2
- package/generate-conlang.js +10 -2
- package/package.json +10 -3
package/README.md
CHANGED
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// fill-orthography.js
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const ipaDir = path.join(process.cwd(), 'ipa');
|
|
8
|
+
const configPath = path.join(ipaDir, 'ipa.config.js');
|
|
9
|
+
const alphabetPath = path.join(ipaDir, 'alphabet.js');
|
|
10
|
+
|
|
11
|
+
// -----------------------------
|
|
12
|
+
// CHECK FILES EXIST
|
|
13
|
+
// -----------------------------
|
|
14
|
+
if (!fs.existsSync(configPath)) {
|
|
15
|
+
console.error('❌ ipa.config.js not found. Run npx ipa-init first.');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(alphabetPath)) {
|
|
20
|
+
console.error('❌ alphabet.js not found. Run npx ipa-init first.');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// -----------------------------
|
|
25
|
+
// LOAD ALPHABET
|
|
26
|
+
// -----------------------------
|
|
27
|
+
const alphabet = require(alphabetPath);
|
|
28
|
+
|
|
29
|
+
if (!Array.isArray(alphabet) || alphabet.length === 0) {
|
|
30
|
+
console.error('❌ alphabet array cannot be empty');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// -----------------------------
|
|
35
|
+
// GENERATE orthography OBJECT STRING
|
|
36
|
+
// -----------------------------
|
|
37
|
+
const orthographyLines = alphabet.map(letter => ` ["${letter}"]: ["", []],`);
|
|
38
|
+
const orthographyString = `const orthography = {\n${orthographyLines.join('\n')}\n};`;
|
|
39
|
+
|
|
40
|
+
// -----------------------------
|
|
41
|
+
// READ EXISTING CONFIG
|
|
42
|
+
// -----------------------------
|
|
43
|
+
let fileText = fs.readFileSync(configPath, 'utf-8');
|
|
44
|
+
|
|
45
|
+
// -----------------------------
|
|
46
|
+
// REPLACE ONLY orthography OBJECT
|
|
47
|
+
// -----------------------------
|
|
48
|
+
fileText = fileText.replace(
|
|
49
|
+
/const orthography\s*=\s*\{[\s\S]*?\};/m,
|
|
50
|
+
orthographyString
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// -----------------------------
|
|
54
|
+
// WRITE BACK UPDATED CONFIG
|
|
55
|
+
// -----------------------------
|
|
56
|
+
fs.writeFileSync(configPath, fileText, 'utf-8');
|
|
57
|
+
console.log(`✅ ipa.config.js updated with ${alphabet.length} letters from alphabet.js`);
|
package/generate-config.js
CHANGED
|
@@ -121,10 +121,23 @@ function generateConfig() {
|
|
|
121
121
|
generateOrthographyExport()
|
|
122
122
|
].join('\n');
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
// Ensure 'ipa' folder exists
|
|
125
|
+
const ipaDir = path.join(process.cwd(), 'ipa');
|
|
126
|
+
if (!fs.existsSync(ipaDir)) {
|
|
127
|
+
fs.mkdirSync(ipaDir, { recursive: true });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Write file inside 'ipa' folder
|
|
131
|
+
const outputPath = path.join(ipaDir, 'ipa.config.js');
|
|
125
132
|
fs.writeFileSync(outputPath, content, 'utf-8');
|
|
126
133
|
|
|
127
|
-
console.log('✅ ipa.config.js generated with parseConfig() export');
|
|
134
|
+
console.log('✅ ipa/ipa.config.js generated with parseConfig() export');
|
|
135
|
+
|
|
136
|
+
// Write alphabet.js
|
|
137
|
+
const alphabetPath = path.join(ipaDir, 'alphabet.js');
|
|
138
|
+
const alphabetContent = 'const alphabet = [];\nmodule.exports = alphabet;\n';
|
|
139
|
+
fs.writeFileSync(alphabetPath, alphabetContent, 'utf-8');
|
|
140
|
+
console.log('✅ ipa/alphabet.js generated with empty alphabet array');
|
|
128
141
|
}
|
|
129
142
|
|
|
130
143
|
// RUN
|
package/generate-conlang.js
CHANGED
|
@@ -111,7 +111,15 @@ async function main() {
|
|
|
111
111
|
affricateChance: aff,
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
// Ensure 'ipa' folder exists
|
|
115
|
+
const ipaDir = path.join(process.cwd(), 'ipa');
|
|
116
|
+
if (!fs.existsSync(ipaDir)) {
|
|
117
|
+
fs.mkdirSync(ipaDir, { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Write file inside 'ipa' folder
|
|
121
|
+
const outPath = path.join(ipaDir, 'generatedConlang.js');
|
|
122
|
+
|
|
115
123
|
const lines = Object.entries(orthography).map(
|
|
116
124
|
([l, v]) => ` ${JSON.stringify(l)}:${JSON.stringify(v)}`
|
|
117
125
|
);
|
|
@@ -119,7 +127,7 @@ async function main() {
|
|
|
119
127
|
const content = `/** Generated conlang orthography */\nconst generatedOrthography = {\n${lines.join(',\n')}\n};\nmodule.exports = generatedOrthography;\n`;
|
|
120
128
|
|
|
121
129
|
fs.writeFileSync(outPath, content, 'utf-8');
|
|
122
|
-
console.log('✅ generatedConlang.js written');
|
|
130
|
+
console.log('✅ ipa/generatedConlang.js written');
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
main();
|
package/package.json
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipa-core",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Language-agnostic IPA core with features",
|
|
5
|
+
"repository": "github:Cody253/ipa-core",
|
|
6
|
+
"homepage": "https://github.com/Cody253/ipa-core#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/Cody253/ipa-core/issues"
|
|
9
|
+
},
|
|
5
10
|
"license": "ISC",
|
|
6
11
|
"author": "Cody Bruno",
|
|
7
12
|
"type": "commonjs",
|
|
8
13
|
"bin": {
|
|
9
14
|
"make-conlang": "generate-conlang.js",
|
|
10
|
-
"ipa-init": "generate-config.js"
|
|
15
|
+
"ipa-init": "generate-config.js",
|
|
16
|
+
"fill-orthography": "fill-orthography.js"
|
|
11
17
|
},
|
|
12
18
|
"main": "index.js",
|
|
13
19
|
"scripts": {
|
|
14
20
|
"test": "node test.js",
|
|
15
21
|
"init:ipa": "node generate-config.js",
|
|
16
|
-
"make-conlang": "node generate-conlang.js"
|
|
22
|
+
"make-conlang": "node generate-conlang.js",
|
|
23
|
+
"fill-orthography": "node fill-orthography.js"
|
|
17
24
|
},
|
|
18
25
|
"keywords": [
|
|
19
26
|
"ipa",
|