automated format generation

This commit is contained in:
Doug Bird 2017-12-13 20:49:59 -08:00
parent f09062c0cc
commit 17424095da
8 changed files with 1084 additions and 56 deletions

4
.gitignore vendored
View File

@ -5,3 +5,7 @@
composer.lock composer.lock
*.log *.log
!**.gitkeep !**.gitkeep
/*-backup.csv
/formats/php/TldEnum/*-backup.php
/formats/json/*-backup.json
/formats/js/*-backup.js

284
assets/tld-desc.csv Normal file
View File

@ -0,0 +1,284 @@
ac,Ascension Island
ad,Andorra (Principality of)
ae,United Arab Emirates
aero,Air-transport industry
af,Afghanistan (Islamic Republic of)
ag,Antigua and Barbuda
ai,Anguilla
al,Albania (Republic of)
am,Armenia (Republic of)
an,Netherlands Antilles
ao,Angola (Republic of)
aq,Antarctica
ar,Argentina (Argentine Republic)
arpa,Address and Routing Parameter Area
as,American Samoa
asia,Organisations and individuals in the Asia-Pacific region
at,Austria (Republic of)
au,Australia (Commonwealth of)
aw,Aruba
ax,Åland Islands
az,Azerbaijan (Republic of)
ba,Bosnia and Herzegovina
bb,Barbados
bd,Bangladesh (People's Republic of)
be,Belgium (Kingdom of)
bf,Burkina Faso
bg,Bulgaria (Republic of)
bh,Bahrain (Kingdom of)
bi,Burundi (Republic of)
biz,Business
bj,Benin (Republic of)
bl,Saint Barthélemy (Collectivity of) {unassigned - see also: .gp and .fr}
bm,Bermuda
bn,Brunei (Nation of Brunei - the Abode of Peace) [Negara Brunei Darussalam]
bo,Bolivia (Plurinational State of)
bq,Caribbean Netherlands [Bonaire - Sint Eustatius and Saba] {unassigned - see also: .an and .nl}
br,Brazil (Federative Republic of)
bs,Bahamas (Commonwealth of the)
bt,Bhutan (Kingdom of)
bv,Bouvet Island
bw,Botswana (Republic of)
by,Belarus (Republic of)
bz,Belize
ca,Canada
cat,Catalan
cc,Cocos (Keeling) Islands (Territory of the)
cd,Congo (Democratic Republic of the) [Congo-Kinshasa]
cf,Central African Republic
cg,Congo (Republic of) [Congo-Brazzaville]
ch,Switzerland (Swiss Confederation)
ci,Ivory Coast (Republic of Côte d'Ivoire)
ck,Cook Islands
cl,Chile (Republic of)
cm,Cameroon (Republic of)
cn,China (People's Republic of)
co,Colombia (Republic of)
com,Commercial organizations
coop,Cooperatives
cr,Costa Rica (Republic of)
cs,Czechoslovakia {formerly - retired 1995 - see also: .cz and .sk}
cu,Cuba (Republic of)
cv,Cape Verde (Republic of)
cw,Curaçao (Country of)
cx,Christmas Island (Territory of)
cy,Cyprus (Republic of)
cz,Czech Republic
dd,German Democratic Republic [East Germany] {formerly - retired}
de,Germany (Federal Republic of)
dj,Djibouti (Republic of)
dk,Denmark (Kingdom of)
dm,Dominica (Commonwealth of)
do,Dominican Republic
dz,Algeria (People's Democratic Republic of)
ec,Ecuador (Republic of)
edu,Educational establishments
ee,Estonia (Republic of)
eg,Egypt (Arab Republic of)
eh,Western Sahara {reserved}
er,Eritrea (State of)
es,Spain (Kingdom of)
et,Ethiopia (Federal Democratic Republic of)
eu,European Union
fi,Finland (Republic of)
fj,Fiji (Republic of)
fk,Falkland Islands (Malvinas)
fm,Micronesia (Federated States of)
fo,Faroe Islands
fr,France (French Republic)
ga,Gabon (Gabonese Republic)
gb,United Kingdom (United Kingdom of Great Britain and Northern Ireland)
gd,Grenada
ge,Georgia
gf,French Guiana
gg,Guernsey (Bailiwick of)
gh,Ghana (Republic of)
gi,Gibraltar
gl,Greenland
gm,Gambia (Republic of The)
gn,Guinea (Republic of)
gov,US government
gp,Guadeloupe
gq,Equatorial Guinea (Republic of)
gr,Greece (Hellenic Republic)
gs,South Georgia and the South Sandwich Islands
gt,Guatemala (Republic of)
gu,Guam
gw,Guinea-Bissau (Republic of)
gy,Guyana (Co-operative Republic of)
hk,Hong Kong (Hong Kong Special Administrative Region of the People's Republic of China)
hm,Heard Island and McDonald Islands
hn,Honduras (Republic of)
hr,Croatia (Republic of)
ht,Haiti (Republic of)
hu,Hungary
id,Indonesia (Republic of)
ie,Ireland (Republic of)
il,Israel (State of)
im,Isle of Man
in,India (Republic of)
info,Informational sites
int,International treaty-based organizations
io,British Indian Ocean Territory
iq,Iraq (Republic of)
ir,Iran (Islamic Republic of)
is,Iceland
it,Italy (Italian Republic)
je,Jersey (Bailiwick of)
jm,Jamaica (Commonwealth of)
jo,Jordan (Hashemite Kingdom of)
jobs,Employment-related sites
jp,Japan
ke,Kenya (Republic of)
kg,Kyrgyzstan (Kyrgyz Republic)
kh,Cambodia (Kingdom of)
ki,Kiribati (Republic of)
km,Comoros (Union of the)
kn,Saint Kitts and Nevis (Federation of)
kp,Korea (Democratic People's Republic of) [North Korea]
kr,Korea (Republic of) [South Korea]
kw,Kuwait (State of Kuwait)
ky,Cayman Islands
kz,Kazakhstan (Republic of)
la,Laos (Lao People's Democratic Republic)
lb,Lebanon (Lebanese Republic)
lc,Saint Lucia
li,Liechtenstein (Principality of)
lk,Sri Lanka (Democratic Socialist Republic of)
local,Pseudo-Domain for Multicast DNS
lr,Liberia (Republic of)
ls,Lesotho (Kingdom of)
lt,Lithuania (Republic of)
lu,Luxembourg (Grand Duchy of)
lv,Latvia (Republic of)
ly,Libya
ma,Morocco
mc,Monaco (Principality of)
md,Moldova (Republic of)
me,Montenegro
mf,Saint Martin (Collectivity of) {unassigned - see also: .gp and .fr}
mg,Madagascar (Republic of)
mh,Marshall Islands (Republic of the)
mil,US military
mk,Macedonia (Republic of)
ml,Mali (Republic of)
mm,Myanmar (Republic of the Union of) [Burma]
mn,Mongolia
mo,Macau (Macau Special Administrative Region of the People's Republic of China) [Macao]
mobi,Mobile
mp,Northern Mariana Islands (Commonwealth of the)
mq,Martinique
mr,Mauritania (Islamic Republic of)
ms,Montserrat
mt,Malta (Republic of)
mu,Mauritius (Republic of)
museum,Museums
mv,Maldives (Republic of)
mw,Malawi (Republic of)
mx,Mexico (United Mexican States)
my,Malaysia
mz,Mozambique (Republic of)
na,Namibia (Republic of)
name,Individuals
nato,NATO sites and operations {formerly - retired 1996 - never used}
nc,New Caledonia
ne,Niger (Republic of)
net,Network
nf,Norfolk Island (Territory of)
ng,Nigeria (Federal Republic of)
ni,Nicaragua (Republic of)
nl,Netherlands
no,Norway (Kingdom of)
np,Nepal (Federal Democratic Republic of)
nr,Nauru (Republic of)
nu,Niue
nz,New Zealand
om,Oman (Sultanate of)
onion,Pseudo-Domain for TOR (The Onion Router)
org,Non-profit organizations
pa,Panama (Republic of)
pe,Peru (Republic of)
pf,French Polynesia and Clipperton Island
pg,Papua New Guinea (Independent State of)
ph,Philippines (Republic of the)
pk,Pakistan (Islamic Republic of)
pl,Poland (Republic of)
pm,Saint Pierre and Miquelon
pn,Pitcairn Islands (Pitcairn - Henderson - Ducie and Oeno Islands)
pr,Puerto Rico (Commonwealth of)
pro,Profession
ps,Palestine (State of)
pt,Portugal (Portuguese Republic)
pw,Palau (Republic of)
py,Paraguay (Republic of)
qa,Qatar (State of)
re,Réunion
ro,Romania
rs,Serbia (Republic of)
ru,Russia (Russian Federation)
rw,Rwanda (Republic of)
sa,Saudi Arabia (Kingdom of)
sb,Solomon Islands
sc,Seychelles (Republic of)
sd,Sudan (Republic of)
se,Sweden (Kingdom of)
sg,Singapore (Republic of)
sh,Saint Helena
si,Slovenia (Republic of)
sj,Svalbard and Jan Mayen {not in use - see also: .no}
sk,Slovakia (Slovak Republic)
sl,Sierra Leone (Republic of)
sm,San Marino (Republic of)
sn,Senegal (Republic of)
so,Somalia (Federal Republic of)
sr,Suriname (Republic of)
ss,South Sudan (Republic of)
st,São Tomé and Príncipe (Democratic Republic of)
su,Soviet Union (Union of Soviet Socialist Republics)
sv,El Salvador (Republic of)
sx,Sint Maarten
sy,Syria (Syrian Arab Republic)
sz,Swaziland (Kingdom of)
tc,Turks and Caicos Islands
td,Chad (Republic of)
tel,Telephone
tf,French Southern and Antarctic Lands (Territory of the)
tg,Togo (Togolese Republic)
th,Thailand (Kingdom of)
tj,Tajikistan (Republic of)
tk,Tokelau
tl,Timor-Leste (Democratic Republic of) [East Timor]
tm,Turkmenistan
tn,Tunisia (Republic of)
to,Tonga (Kingdom of)
tp,Timor-Leste (Democratic Republic of) [East Timor] {being phased out - also see: .tl}
tr,Turkey (Republic of)
travel,Travel
tt,Trinidad and Tobago (Republic of)
tv,Tuvalu
tw,Taiwan (Republic of China)
tz,Tanzania (United Republic of)
ua,Ukraine
ug,Uganda (Republic of)
uk,United Kingdom (United Kingdom of Great Britain and Northern Ireland)
um,United States Minor Outlying Islands {formerly - retired 2010 - see also: .us}
us,United States of America and United States Minor Outlying Islands
uy,Uruguay (Oriental Republic of)
uz,Uzbekistan (Republic of)
va,Vatican City (Vatican City State)
vc,Saint Vincent and the Grenadines
ve,Venezuela (Bolivarian Republic of)
vg,British Virgin Islands (Virgin Islands)
vi,United States Virgin Islands (United States Virgin Islands)
vn,Vietnam (Socialist Republic of)
vu,Vanuatu (Republic of)
wf,Wallis and Futuna (Territory of the Wallis and Futuna Islands)
ws,Samoa (Independent State of)
xxx,Adult entertainment
ye,Yemen (Republic of)
yt,Mayotte (Department of)
yu,Yugoslavia and Serbia and Montenegro {formerly - retired 2010 - see also: .me and .rs}
za,South Africa (Republic of)
zm,Zambia (Republic of)
zr,Zaire (Republic of) {formerly - retired 2001 - see also: .cd}
zw,Zimbabwe (Republic of)
1 ac Ascension Island
2 ad Andorra (Principality of)
3 ae United Arab Emirates
4 aero Air-transport industry
5 af Afghanistan (Islamic Republic of)
6 ag Antigua and Barbuda
7 ai Anguilla
8 al Albania (Republic of)
9 am Armenia (Republic of)
10 an Netherlands Antilles
11 ao Angola (Republic of)
12 aq Antarctica
13 ar Argentina (Argentine Republic)
14 arpa Address and Routing Parameter Area
15 as American Samoa
16 asia Organisations and individuals in the Asia-Pacific region
17 at Austria (Republic of)
18 au Australia (Commonwealth of)
19 aw Aruba
20 ax Åland Islands
21 az Azerbaijan (Republic of)
22 ba Bosnia and Herzegovina
23 bb Barbados
24 bd Bangladesh (People's Republic of)
25 be Belgium (Kingdom of)
26 bf Burkina Faso
27 bg Bulgaria (Republic of)
28 bh Bahrain (Kingdom of)
29 bi Burundi (Republic of)
30 biz Business
31 bj Benin (Republic of)
32 bl Saint Barthélemy (Collectivity of) {unassigned - see also: .gp and .fr}
33 bm Bermuda
34 bn Brunei (Nation of Brunei - the Abode of Peace) [Negara Brunei Darussalam]
35 bo Bolivia (Plurinational State of)
36 bq Caribbean Netherlands [Bonaire - Sint Eustatius and Saba] {unassigned - see also: .an and .nl}
37 br Brazil (Federative Republic of)
38 bs Bahamas (Commonwealth of the)
39 bt Bhutan (Kingdom of)
40 bv Bouvet Island
41 bw Botswana (Republic of)
42 by Belarus (Republic of)
43 bz Belize
44 ca Canada
45 cat Catalan
46 cc Cocos (Keeling) Islands (Territory of the)
47 cd Congo (Democratic Republic of the) [Congo-Kinshasa]
48 cf Central African Republic
49 cg Congo (Republic of) [Congo-Brazzaville]
50 ch Switzerland (Swiss Confederation)
51 ci Ivory Coast (Republic of Côte d'Ivoire)
52 ck Cook Islands
53 cl Chile (Republic of)
54 cm Cameroon (Republic of)
55 cn China (People's Republic of)
56 co Colombia (Republic of)
57 com Commercial organizations
58 coop Cooperatives
59 cr Costa Rica (Republic of)
60 cs Czechoslovakia {formerly - retired 1995 - see also: .cz and .sk}
61 cu Cuba (Republic of)
62 cv Cape Verde (Republic of)
63 cw Curaçao (Country of)
64 cx Christmas Island (Territory of)
65 cy Cyprus (Republic of)
66 cz Czech Republic
67 dd German Democratic Republic [East Germany] {formerly - retired}
68 de Germany (Federal Republic of)
69 dj Djibouti (Republic of)
70 dk Denmark (Kingdom of)
71 dm Dominica (Commonwealth of)
72 do Dominican Republic
73 dz Algeria (People's Democratic Republic of)
74 ec Ecuador (Republic of)
75 edu Educational establishments
76 ee Estonia (Republic of)
77 eg Egypt (Arab Republic of)
78 eh Western Sahara {reserved}
79 er Eritrea (State of)
80 es Spain (Kingdom of)
81 et Ethiopia (Federal Democratic Republic of)
82 eu European Union
83 fi Finland (Republic of)
84 fj Fiji (Republic of)
85 fk Falkland Islands (Malvinas)
86 fm Micronesia (Federated States of)
87 fo Faroe Islands
88 fr France (French Republic)
89 ga Gabon (Gabonese Republic)
90 gb United Kingdom (United Kingdom of Great Britain and Northern Ireland)
91 gd Grenada
92 ge Georgia
93 gf French Guiana
94 gg Guernsey (Bailiwick of)
95 gh Ghana (Republic of)
96 gi Gibraltar
97 gl Greenland
98 gm Gambia (Republic of The)
99 gn Guinea (Republic of)
100 gov US government
101 gp Guadeloupe
102 gq Equatorial Guinea (Republic of)
103 gr Greece (Hellenic Republic)
104 gs South Georgia and the South Sandwich Islands
105 gt Guatemala (Republic of)
106 gu Guam
107 gw Guinea-Bissau (Republic of)
108 gy Guyana (Co-operative Republic of)
109 hk Hong Kong (Hong Kong Special Administrative Region of the People's Republic of China)
110 hm Heard Island and McDonald Islands
111 hn Honduras (Republic of)
112 hr Croatia (Republic of)
113 ht Haiti (Republic of)
114 hu Hungary
115 id Indonesia (Republic of)
116 ie Ireland (Republic of)
117 il Israel (State of)
118 im Isle of Man
119 in India (Republic of)
120 info Informational sites
121 int International treaty-based organizations
122 io British Indian Ocean Territory
123 iq Iraq (Republic of)
124 ir Iran (Islamic Republic of)
125 is Iceland
126 it Italy (Italian Republic)
127 je Jersey (Bailiwick of)
128 jm Jamaica (Commonwealth of)
129 jo Jordan (Hashemite Kingdom of)
130 jobs Employment-related sites
131 jp Japan
132 ke Kenya (Republic of)
133 kg Kyrgyzstan (Kyrgyz Republic)
134 kh Cambodia (Kingdom of)
135 ki Kiribati (Republic of)
136 km Comoros (Union of the)
137 kn Saint Kitts and Nevis (Federation of)
138 kp Korea (Democratic People's Republic of) [North Korea]
139 kr Korea (Republic of) [South Korea]
140 kw Kuwait (State of Kuwait)
141 ky Cayman Islands
142 kz Kazakhstan (Republic of)
143 la Laos (Lao People's Democratic Republic)
144 lb Lebanon (Lebanese Republic)
145 lc Saint Lucia
146 li Liechtenstein (Principality of)
147 lk Sri Lanka (Democratic Socialist Republic of)
148 local Pseudo-Domain for Multicast DNS
149 lr Liberia (Republic of)
150 ls Lesotho (Kingdom of)
151 lt Lithuania (Republic of)
152 lu Luxembourg (Grand Duchy of)
153 lv Latvia (Republic of)
154 ly Libya
155 ma Morocco
156 mc Monaco (Principality of)
157 md Moldova (Republic of)
158 me Montenegro
159 mf Saint Martin (Collectivity of) {unassigned - see also: .gp and .fr}
160 mg Madagascar (Republic of)
161 mh Marshall Islands (Republic of the)
162 mil US military
163 mk Macedonia (Republic of)
164 ml Mali (Republic of)
165 mm Myanmar (Republic of the Union of) [Burma]
166 mn Mongolia
167 mo Macau (Macau Special Administrative Region of the People's Republic of China) [Macao]
168 mobi Mobile
169 mp Northern Mariana Islands (Commonwealth of the)
170 mq Martinique
171 mr Mauritania (Islamic Republic of)
172 ms Montserrat
173 mt Malta (Republic of)
174 mu Mauritius (Republic of)
175 museum Museums
176 mv Maldives (Republic of)
177 mw Malawi (Republic of)
178 mx Mexico (United Mexican States)
179 my Malaysia
180 mz Mozambique (Republic of)
181 na Namibia (Republic of)
182 name Individuals
183 nato NATO sites and operations {formerly - retired 1996 - never used}
184 nc New Caledonia
185 ne Niger (Republic of)
186 net Network
187 nf Norfolk Island (Territory of)
188 ng Nigeria (Federal Republic of)
189 ni Nicaragua (Republic of)
190 nl Netherlands
191 no Norway (Kingdom of)
192 np Nepal (Federal Democratic Republic of)
193 nr Nauru (Republic of)
194 nu Niue
195 nz New Zealand
196 om Oman (Sultanate of)
197 onion Pseudo-Domain for TOR (The Onion Router)
198 org Non-profit organizations
199 pa Panama (Republic of)
200 pe Peru (Republic of)
201 pf French Polynesia and Clipperton Island
202 pg Papua New Guinea (Independent State of)
203 ph Philippines (Republic of the)
204 pk Pakistan (Islamic Republic of)
205 pl Poland (Republic of)
206 pm Saint Pierre and Miquelon
207 pn Pitcairn Islands (Pitcairn - Henderson - Ducie and Oeno Islands)
208 pr Puerto Rico (Commonwealth of)
209 pro Profession
210 ps Palestine (State of)
211 pt Portugal (Portuguese Republic)
212 pw Palau (Republic of)
213 py Paraguay (Republic of)
214 qa Qatar (State of)
215 re Réunion
216 ro Romania
217 rs Serbia (Republic of)
218 ru Russia (Russian Federation)
219 rw Rwanda (Republic of)
220 sa Saudi Arabia (Kingdom of)
221 sb Solomon Islands
222 sc Seychelles (Republic of)
223 sd Sudan (Republic of)
224 se Sweden (Kingdom of)
225 sg Singapore (Republic of)
226 sh Saint Helena
227 si Slovenia (Republic of)
228 sj Svalbard and Jan Mayen {not in use - see also: .no}
229 sk Slovakia (Slovak Republic)
230 sl Sierra Leone (Republic of)
231 sm San Marino (Republic of)
232 sn Senegal (Republic of)
233 so Somalia (Federal Republic of)
234 sr Suriname (Republic of)
235 ss South Sudan (Republic of)
236 st São Tomé and Príncipe (Democratic Republic of)
237 su Soviet Union (Union of Soviet Socialist Republics)
238 sv El Salvador (Republic of)
239 sx Sint Maarten
240 sy Syria (Syrian Arab Republic)
241 sz Swaziland (Kingdom of)
242 tc Turks and Caicos Islands
243 td Chad (Republic of)
244 tel Telephone
245 tf French Southern and Antarctic Lands (Territory of the)
246 tg Togo (Togolese Republic)
247 th Thailand (Kingdom of)
248 tj Tajikistan (Republic of)
249 tk Tokelau
250 tl Timor-Leste (Democratic Republic of) [East Timor]
251 tm Turkmenistan
252 tn Tunisia (Republic of)
253 to Tonga (Kingdom of)
254 tp Timor-Leste (Democratic Republic of) [East Timor] {being phased out - also see: .tl}
255 tr Turkey (Republic of)
256 travel Travel
257 tt Trinidad and Tobago (Republic of)
258 tv Tuvalu
259 tw Taiwan (Republic of China)
260 tz Tanzania (United Republic of)
261 ua Ukraine
262 ug Uganda (Republic of)
263 uk United Kingdom (United Kingdom of Great Britain and Northern Ireland)
264 um United States Minor Outlying Islands {formerly - retired 2010 - see also: .us}
265 us United States of America and United States Minor Outlying Islands
266 uy Uruguay (Oriental Republic of)
267 uz Uzbekistan (Republic of)
268 va Vatican City (Vatican City State)
269 vc Saint Vincent and the Grenadines
270 ve Venezuela (Bolivarian Republic of)
271 vg British Virgin Islands (Virgin Islands)
272 vi United States Virgin Islands (United States Virgin Islands)
273 vn Vietnam (Socialist Republic of)
274 vu Vanuatu (Republic of)
275 wf Wallis and Futuna (Territory of the Wallis and Futuna Islands)
276 ws Samoa (Independent State of)
277 xxx Adult entertainment
278 ye Yemen (Republic of)
279 yt Mayotte (Department of)
280 yu Yugoslavia and Serbia and Montenegro {formerly - retired 2010 - see also: .me and .rs}
281 za South Africa (Republic of)
282 zm Zambia (Republic of)
283 zr Zaire (Republic of) {formerly - retired 2001 - see also: .cd}
284 zw Zimbabwe (Republic of)

107
bin/helpers/generate-js-tld-enum.js Normal file → Executable file
View File

@ -1,7 +1,106 @@
#!/usr/bin/env node #!/usr/bin/env node
console.log("generates the 'tld-enum.js' node source file from the 'tlds.csv' csv file"); const meName = 'generate-js-tld-enum.js';
console.log("---this script is currently a 'to-do' placeholder!---");
console.error("terminating... the development for the 'JSON' format generator has not yet been completed");
process.exit(1); process.on('unhandledRejection', error => {
console.error(meName + ": (FATAL)", error);
process.exit(1);
});
const countries = require('country-data').countries;
const country = require('countryjs');
const parse = require('csv-parse');
const fs = require('fs-extra');
const path = require('path');
const md5File = require('md5-file/promise');
const pathinfo = require('pathinfo');
const program = require('commander');
const tmp = require('tmp');
//tmp.setGracefulCleanup();
const fileTldListJs = path.dirname(require.main.filename) + '/../../formats/js/tld-enum.js';
const fileTldsCsv = path.dirname(require.main.filename) + '/../../tlds.csv';
program
.option('-q, --quiet', 'Quiet Mode')
.parse(process.argv);
if (!program.quiet) {
console.log(meName);
console.log(" (c) 2017 Doug Bird, All Rights Reserved.");
console.log(" see README.md for licensing and other information");
console.log(" https://github.com/katmore/tld-enum#readme");
console.log("");
console.log(" Generates new javascript format files from the 'tlds.csv' file");
console.log("");
}
(async() => {
const tldEnumStartTldList = 'exports.tldList = ';
const tldEnumEndTldList = ';';
//const tmpDir = tmp.dirSync({ unsafeCleanup: true });
const tmpDir = tmp.dirSync();
const fileNewTldListJs = tmpDir.name + '/tld-enum.js';
let existingMd5 = null;
if (fs.existsSync(fileTldListJs)) {
existingMd5 = await md5File(fileTldListJs);
const pathinfoTlds = pathinfo(fileTldListJs);
const fileBackupTlds = pathinfoTlds.dirname + pathinfoTlds.sep + pathinfoTlds.basename + '-' + existingMd5 + '-backup.js';
if (!fs.existsSync(fileBackupTlds)) {
fs.copySync(fileTldListJs, fileBackupTlds);
}
}
process.stdout.write("reading 'tlds.csv'...");
let parser = parse({ delimiter: ',' });
let tldEnum = [];
parser.on('readable', function() {
let i = 0;
let row;
while (row = parser.read()) {
if (!row.length) {
console.error(meName + ": (FATAL) invalid 'tlds.csv' row #" + i + ": " + fileTldsCsv);
process.exit(1);
}
tldEnum.push(row[0]);
i++;
}
});
parser.write(fs.readFileSync(fileTldsCsv));
parser.end();
console.log("done");
process.stdout.write("generating new 'tld-enum.js' file...");
fs.writeFileSync(fileNewTldListJs, tldEnumStartTldList);
fs.appendFileSync(fileNewTldListJs, JSON.stringify(tldEnum, null, 2));
fs.appendFileSync(fileNewTldListJs, tldEnumEndTldList);
console.log("done");
if (existingMd5) {
const newMd5 = await md5File(fileNewTldListJs);
if (newMd5 == existingMd5) {
console.error(meName + ": (NOTICE) ignoring newly generated 'tld-enum.js' file that is identical to the existing file (md5: " + existingMd5 + ", path: " + fileTldListJs + ")");
return;
}
}
fs.copySync(fileNewTldListJs, fileTldListJs);
console.log("saved new 'tld-enum.js' file");
})();

98
bin/helpers/generate-json-tld-enum.js Normal file → Executable file
View File

@ -1,7 +1,97 @@
#!/usr/bin/env node #!/usr/bin/env node
console.log("generates the 'tld-list.json' JSON array file from the 'tlds.csv' csv file"); const meName = 'generate-json-tld-enum.js';
console.log("---this script is currently a 'to-do' placeholder!---");
console.error("terminating... the development for the 'JSON' format generator has not yet been completed");
process.exit(1); process.on('unhandledRejection', error => {
console.error(meName + ": (FATAL)", error);
process.exit(1);
});
const countries = require('country-data').countries;
const country = require('countryjs');
const parse = require('csv-parse');
const fs = require('fs-extra');
const path = require('path');
const md5File = require('md5-file/promise');
const pathinfo = require('pathinfo');
const program = require('commander');
const tmp = require('tmp');
tmp.setGracefulCleanup();
const fileTldListJson = path.dirname(require.main.filename) + '/../../formats/json/tld-list.json';
const fileTldsCsv = path.dirname(require.main.filename) + '/../../tlds.csv';
program
.option('-q, --quiet', 'Quiet Mode')
.parse(process.argv);
if (!program.quiet) {
console.log(meName);
console.log(" (c) 2017 Doug Bird, All Rights Reserved.");
console.log(" see README.md for licensing and other information");
console.log(" https://github.com/katmore/tld-enum#readme");
console.log("");
console.log(" Generates new JSON format files from the 'tlds.csv' file");
console.log("");
}
(async() => {
const tmpDir = tmp.dirSync({ unsafeCleanup: true });
const fileNewTldListJson = tmpDir.name + '/tld-list.json';
let existingMd5 = null;
if (fs.existsSync(fileTldListJson)) {
existingMd5 = await md5File(fileTldListJson);
const pathinfoTlds = pathinfo(fileTldListJson);
const fileBackupTlds = pathinfoTlds.dirname + pathinfoTlds.sep + pathinfoTlds.basename + '-' + existingMd5 + '-backup.json';
if (!fs.existsSync(fileBackupTlds)) {
fs.copySync(fileTldListJson, fileBackupTlds);
}
}
process.stdout.write("reading 'tlds.csv'...");
let parser = parse({ delimiter: ',' });
let tldEnum = [];
parser.on('readable', function() {
let i = 0;
let row;
while (row = parser.read()) {
if (!row.length) {
console.error(meName + ": (FATAL) invalid 'tlds.csv' row #" + i + ": " + fileTldsCsv);
process.exit(1);
}
tldEnum.push(row[0]);
i++;
}
});
parser.write(fs.readFileSync(fileTldsCsv));
parser.end();
console.log("done");
process.stdout.write("generating new 'tld-list.json' file...");
fs.writeFileSync(fileNewTldListJson, JSON.stringify(tldEnum, null, 2));
console.log("done");
if (existingMd5) {
const newMd5 = await md5File(fileNewTldListJson);
if (newMd5 == existingMd5) {
console.error(meName + ": (NOTICE) ignoring newly generated 'tld-list.json' file that is identical to the existing file (md5: " + existingMd5 + ", path: " + fileTldListJson + ")");
return;
}
}
fs.copySync(fileNewTldListJson, fileTldListJson);
console.log("saved new 'tld-list.json' file");
})();

184
bin/helpers/generate-php-tld-enum.php Normal file → Executable file
View File

@ -1,17 +1,179 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
(function() { new class() {
const ME_NAME = 'generate-php-tld-enum.php';
const TLDS_CSV_PATH = __DIR__ . '/../../tlds.csv';
const TLD_ENUM_PATH = __DIR__ . '/../../formats/php/TldEnum/TldEnum.php';
private static $_quietMode = false;
public function __construct() {
$opt = getopt ( "q",['quiet']);
if (isset($opt['q']) || isset($opt['quiet'])) {
static::$_quietMode = true;
}
echo "generates the 'TldEnum.php' class definition file from the 'tlds.csv' csv file"; if (!static::$_quietMode) {
echo static::ME_NAME."\n";
echo " (c) 2017 Doug Bird, All Rights Reserved.\n";
echo " see README.md for licensing and other information\n";
echo " https://github.com/katmore/tld-enum#readme\n";
echo "\n";
echo " Generates new PHP format files from the 'tlds.csv' file\n";
echo "\n";
}
echo "---this script is currently a 'to-do' placeholder!---"; $fileTldsCsv = static::TLDS_CSV_PATH;
$exit_message = "terminating... the development for the 'PHP' format generator has not yet been completed"; if (!is_file($fileTldsCsv) || !is_readable($fileTldsCsv)) {
static::_echo_error("(FATAL) not a readable path to 'tlds.csv': $fileTldsCsv",1);
}
if (\PHP_SAPI=='cli') { $tldEnumFile = static::TLD_ENUM_PATH;
fwrite(\STDERR,$exit_message); $tldEnumDir = pathinfo($tldEnumFile,\PATHINFO_DIRNAME);
} else { if (file_exists($tldEnumFile)) {
echo $exit_message ; if (!is_file($tldEnumFile)) {
} static::_echo_error("(FATAL) existing path for 'TldEnum.php' was not a file as expected: $tldEnumFile",1);
exit(1); }
})(); if (!is_writable($tldEnumFile)) {
static::_echo_error("(FATAL) existing path for 'TldEnum.php' is not writable: $tldEnumFile",1);
}
} else {
if (!file_exists($tldEnumDir) || !is_dir($tldEnumDir)) {
static::_echo_error("(FATAL) path for 'TldEnum.php' directory does not exist as expected: $tldEnumDir",1);
}
if (!is_writable($tldEnumDir)) {
static::_echo_error("(FATAL) path for 'TldEnum.php' directory is not writeable: $tldEnumDir",1);
}
}
$existingMd5 = null;
if (file_exists($tldEnumFile)) {
$existingMd5 = md5_file($tldEnumFile);
$tldEnumBasename = pathinfo($tldEnumFile,\PATHINFO_FILENAME);
$backupTldEnumFile = $tldEnumDir . \DIRECTORY_SEPARATOR . "$tldEnumBasename-$existingMd5-backup.php";
if (!file_exists($backupTldEnumFile)) {
if (!copy($tldEnumFile,$backupTldEnumFile)) {
static::_echo_error("(FATAL) failed to create backup for 'TldEnum.php' (source: $tldEnumFile, dest: $backupTldEnumFile)",1);
}
}
}
if (false === ($newTldEnumFile = tempnam ( sys_get_temp_dir() , 'tld-enum-' ))) {
static::_echo_error("(FATAL) unable to initialize new 'TldEnum.php' file",1);
}
register_shutdown_function(function() use($newTldEnumFile) {
if (is_file($newTldEnumFile) && is_writable($newTldEnumFile)) {
unlink($newTldEnumFile);
}
});
$tldEnum = [];
if (($handle = fopen($fileTldsCsv, "r")) === false) {
static::_echo_error("(FATAL) unable to open 'tlds.csv' in read mode: $fileTldsCsv",1);
} else {
echo "reading 'tlds.csv'...";
$i=0;
while (($row = fgetcsv($handle, 1000, ",")) !== false) {
if (!count($row)) {
static::_echo_error("(FATAL) invalid 'tlds.csv' row #$i: $fileTldsCsv",1);
}
//echo $row[0]."\n";
$tldEnum []= $row[0];
$i++;
}
fclose($handle);
echo "done\n";
}
//echo "new TldEnum.php: $newTldEnumFile\n";
echo "generating new 'TldEnum.php' file...";
if (false === file_put_contents($newTldEnumFile,static::TLD_ENUM_SOURCE_START_CLASS)) {
static::_echo_error("(FATAL) failed to write to new 'TldEnum.php' file",1);
}
if (false === file_put_contents($newTldEnumFile,static::TLD_ENUM_SOURCE_START_TLD_ENUM_CONST,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldEnum.php' file",1);
}
$tldEnumExport = var_export($tldEnum, true);
$tldEnumExport = str_replace('array','',$tldEnumExport);
$tldEnumExport = str_replace('(','[',$tldEnumExport);
$tldEnumExport = str_replace(')',']',$tldEnumExport);
$tldEnumExport = str_replace('=>','',$tldEnumExport);
$tldEnumExport = preg_replace('/[0-9]+/', '', $tldEnumExport);
//$tldEnumExport = json_encode($tldEnum,\JSON_PRETTY_PRINT);
if (false === file_put_contents($newTldEnumFile, $tldEnumExport,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldEnum.php' file",1);
}
if (false === file_put_contents($newTldEnumFile,static::TLD_ENUM_SOURCE_END_TLD_ENUM_CONST,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldEnum.php' file",1);
}
if (false === file_put_contents($newTldEnumFile,static::TLD_ENUM_SOURCE_END_CLASS,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldEnum.php' file",1);
}
echo "done\n";
if ($existingMd5!==null) {
$newTldEnumMd5 = md5_file($newTldEnumFile);
if ($existingMd5 == $newTldEnumMd5) {
static::_echo_error("(NOTICE) ignoring newly generated 'TldEnum.php' file that is identical to the existing file (md5: $existingMd5, path: $tldEnumFile)");
return;
}
if (!unlink($tldEnumFile)) {
static::_echo_error("(FATAL) failed to remove stale 'TldEnum.php': $tldEnumFile",1);
}
}
if (!copy($newTldEnumFile,$tldEnumFile)) {
static::_echo_error("(FATAL) failed to save new 'TldEnum.php': $tldEnumFile",1);
}
echo "saved new 'TldEnum.php' file\n";
}
private static function _echo_error(string $str, int $fatal_exit_status=null) : void {
if (substr($str,0,1)!=="\n") {
$str .= "\n";
}
$str = static::ME_NAME . ": ".$str;
if (\PHP_SAPI=='cli') {
fwrite(\STDERR,$str);
} else {
echo $str ;
}
if (is_int($fatal_exit_status)) {
exit($fatal_exit_status);
}
}
const TLD_ENUM_SOURCE_START_CLASS = <<<SOURCE
<?php
namespace TldEnum;
class TldEnum {
SOURCE;
const TLD_ENUM_SOURCE_START_TLD_ENUM_CONST = <<<SOURCE
const TLD_ENUM =
SOURCE;
const TLD_ENUM_SOURCE_END_TLD_ENUM_CONST = <<<SOURCE
;
SOURCE;
const TLD_ENUM_SOURCE_END_CLASS = <<<SOURCE
}
SOURCE;
};

View File

@ -1,6 +1,227 @@
#!/usr/bin/env node #!/usr/bin/env node
console.log("generates the canonical 'tlds.csv' csv file"); const meName = 'generate-tlds-csv.js';
console.log("downloads the 'http://data.iana.org/TLD/tlds-alpha-by-domain.txt' file and cross references it with https://www.iana.org/domains/root/db to re-generate the 'tlds.csv' csv file");
process.exit(1); process.on('unhandledRejection', error => {
console.error(meName + ": (FATAL)", error);
process.exit(1);
});
const request = require('async-request');
const cheerio = require('cheerio');
const countries = require('country-data').countries;
const country = require('countryjs');
const stringify = require('csv-stringify');
const parse = require('csv-parse');
const fs = require('fs-extra');
const path = require('path');
const md5File = require('md5-file/promise');
const pathinfo = require('pathinfo');
const program = require('commander');
const tmp = require('tmp');
tmp.setGracefulCleanup();
const fileTldDescCsv = path.dirname(require.main.filename) + '/../../assets/tld-desc.csv';
const fileTldsCsv = path.dirname(require.main.filename) + '/../../tlds.csv';
const urlTldsAlpha = 'http://data.iana.org/TLD/tlds-alpha-by-domain.txt';
const urlDomainsDb = 'https://www.iana.org/domains/root/db';
program
.option('-q, --quiet', 'Quiet Mode')
.parse(process.argv);
if (!program.quiet) {
console.log(meName);
console.log(" (c) 2017 Doug Bird, All Rights Reserved.");
console.log(" see README.md for licensing and other information");
console.log(" https://github.com/katmore/tld-enum#readme");
console.log("");
console.log(" Generates the canonical 'tlds.csv' csv file by downloading resources from iana.org");
console.log("");
}
(async() => {
const tmpDir = tmp.dirSync({ unsafeCleanup: true });
process.stdout.write("downloading '" + urlTldsAlpha + "'...");
const responseTldsAlpha = await request(urlTldsAlpha);
if (responseTldsAlpha.statusCode != 200) {
console.log("error");
console.error(meName + ": (FATAL) response status code " + responseTldsAlpha.statusCode + " from URL '" + urlTldsAlpha + "'");
process.exit(1);
return;
}
if (!responseTldsAlpha.body) {
console.log("error");
console.error(meName + ": (FATAL) empty response body " + responseTldsAlpha.statusCode + " from URL '" + urlTldsAlpha + "'");
process.exit(1);
return;
}
const fileTldsAlphaTxt = tmpDir.name + '/tlds-alpha-by-domain.txt';
const fileNewTldsCsv = tmpDir.name + '/tlds.csv';
fs.writeFileSync(fileTldsAlphaTxt, responseTldsAlpha.body, 'utf8');
fs.writeFileSync(fileNewTldsCsv, '', 'utf8');
console.log('success');
process.stdout.write("downloading '" + urlDomainsDb + "'...");
const responseDomainsDb = await request(urlDomainsDb);
if (responseDomainsDb.statusCode != 200) {
console.log("error");
console.error(meName + ": (FATAL) response status code " + responseDomainsDb.statusCode + " from URL '" + urlDomainsDb + "'");
process.exit(1);
return;
}
if (!responseDomainsDb.body) {
console.log("error");
console.error(meName + ": (FATAL) empty response body " + responseDomainsDb.statusCode + " from URL '" + urlDomainsDb + "'");
process.exit(1);
return;
}
const htmlDomainsDb = responseDomainsDb.body;
var $ = cheerio.load(htmlDomainsDb);
console.log('success');
process.stdout.write("building country / TLD hashmap...");
let tld2CountryName = {};
let missingTld = [];
countries.all.forEach((c) => {
let tld = country.tld(c.alpha3, 'ISO3');
if (!tld) {
missingTld.push(c.alpha3);
return;
}
tld2CountryName[tld] = c.name;
});
console.log('done');
//console.error('NOTICE: the following "countries" did not have an assigned top level domain: ' + missingTld.join(', '));
process.stdout.write("building description / TLD hashmap...");
let tld2Desc = {};
let parser = parse({ delimiter: ',' });
const csvPosMap = {
domain: 0,
description: 1,
}
parser.on('readable', function() {
let tldData;
while (tldData = parser.read()) {
let tld = {
domain: null,
description: null,
};
let prop;
for (prop in tld) {
if (typeof(tldData[csvPosMap[prop]]) !== 'undefined') {
tld[prop] = tldData[csvPosMap[prop]];
}
}
if (tld.domain && tld.description) {
tld2Desc[tld.domain] = tld.description;
}
}
});
parser.write(fs.readFileSync(fileTldDescCsv));
parser.end();
console.log("done");
const tdPosMap = {
domain: 0,
type: 1,
manager: 2,
};
let tldSet = [];
process.stdout.write("parsing IANA data...");
$('#tld-table').find('tr').each((i, element) => {
let tld = {
domain: null,
type: null,
manager: null,
};
let tldData = [];
// console.log('i ' + i);
// console.log(element);
$(element).find("td").each((iTd, elementTd) => {
// console.log('iTd...');
// console.log(iTd);
tldData.push($(elementTd).text());
});
for (var prop in tld) {
if (typeof(tldData[tdPosMap[prop]]) !== 'undefined') {
tld[prop] = tldData[tdPosMap[prop]];
}
}
if (!tld.domain) {
return;
}
tld.domain = tld.domain.replace(/\s/g, '').replace(/\./g, '');
tldSet.push(tld);
});
console.log('done');
const stringifier = stringify({ delimiter: ',' });
stringifier.on('readable', () => {
let row;
while (row = stringifier.read()) {
fs.appendFileSync(fileNewTldsCsv, row, 'utf8')
}
});
process.stdout.write("serializing new 'tlds.csv'...");
for (var i = 0; i < tldSet.length; i++) {
let tld = tldSet[i];
let csvRow = [tld.domain];
if ((tld.type == 'country-code') && (typeof(tld2CountryName[tld.domain]) !== 'undefined')) {
csvRow.push(tld2CountryName[tld.domain]);
} else {
if (typeof(tld2Desc[tld.domain]) !== 'undefined') {
csvRow.push(tld2Desc[tld.domain]);
} else {
csvRow.push(tld.manager);
}
}
csvRow.push(tld.type);
stringifier.write(csvRow);
}
stringifier.end();
console.log('done');
if (fs.existsSync(fileTldsCsv)) {
const newMd5 = await md5File(fileNewTldsCsv);
const csvMd5 = await md5File(fileTldsCsv);
if (csvMd5 == newMd5) {
console.error(meName + ": (NOTICE) ignoring newly generated 'tlds.csv' file that is identical to the existing file (md5: " + csvMd5 + ", path: " + fileTldsCsv + ")");
return;
}
const pathinfoTldsCsv = pathinfo(fileTldsCsv);
const fileBackupTldsCsv = pathinfoTldsCsv.dirname + pathinfoTldsCsv.sep + pathinfoTldsCsv.basename + '-' + csvMd5 + '-backup.csv';
if (!fs.existsSync(fileBackupTldsCsv)) {
fs.copySync(fileTldsCsv, fileBackupTldsCsv);
}
}
process.stdout.write("saving new 'tlds.csv'...");
fs.copySync(fileNewTldsCsv, fileTldsCsv);
console.log('done');
})();

163
bin/update-formats Normal file → Executable file
View File

@ -1,4 +1,161 @@
#!/usr/bin/env node #!/bin/bash
################################################################################
## "update-formats"
## Updates the 'tlds.csv' file from iana.org and re-generates the native
## format files
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
## script localization
################################################################################
ME_NAME="update-formats"
ME_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HELPER_DIR=$ME_DIR/helpers
################################################################################
## enforce dependencies
################################################################################
DEPENDENCY_SET=(node php)
DEPENDENCY_STATUS=0
for DEP_CMD in "${DEPENDENCY_SET[@]}"
do
which $DEP_CMD > /dev/null 2>&1
DEP_STATUS=$?
if [ "$DEP_STATUS" -ne "0" ]; then
>&2 echo -e "$ME_NAME: (NOTICE) failed dependency check for '$DEP_CMD', command is missing or inaccessible"
DEPENDENCY_STATUS=1
fi
done
if [ "$DEPENDENCY_STATUS" -ne "0" ]; then
>&2 echo -e "$ME_NAME: (FATAL) one or more dependency checks failed"
exit 1
fi
################################################################################
## read options and flags
################################################################################
QUIET_MODE=0
typeset -A SCRIPT_OPTS_MAP
SCRIPT_OPTS_MAP=(
[quiet]=q
)
SCRIPT_OPTS="::-:q"
#== parse options ==#
while getopts ${SCRIPT_OPTS} OPTION ; do
#== translate long options to short ==#
OPTREF="-$OPTARG"
if [[ "x$OPTION" == "x-" ]]; then
LONG_OPTION=$OPTARG
LONG_OPTARG=$(echo $LONG_OPTION | grep "=" | cut -d'=' -f2)
LONG_OPTIND=-1
[[ "x$LONG_OPTARG" = "x" ]] && LONG_OPTIND=$OPTIND || LONG_OPTION=$(echo $OPTARG | cut -d'=' -f1)
[[ $LONG_OPTIND -ne -1 ]] && eval LONG_OPTARG="\$$LONG_OPTIND"
OPTION=${SCRIPT_OPTS_MAP[$LONG_OPTION]}
[[ "x$OPTION" = "x" ]] && OPTION="?" OPTARG="-$LONG_OPTION"
OPTREF="--$LONG_OPTION"
if [[ $( echo "${SCRIPT_OPTS}" | grep -c "${OPTION}:" ) -eq 1 ]]; then
if [[ "x${LONG_OPTARG}" = "x" ]] || [[ "${LONG_OPTARG}" = -* ]]; then
OPTION=":" OPTARG="-$LONG_OPTION"
else
OPTARG="$LONG_OPTARG";
if [[ $LONG_OPTIND -ne -1 ]]; then
[[ $OPTIND -le $Optnum ]] && OPTIND=$(( $OPTIND+1 ))
shift $OPTIND
OPTIND=1
fi
fi
fi
fi
console.log("updates the 'tlds.csv' file from iana.org and re-generates the native format files in the 'format/' directory"); #== options follow by another option instead of argument ==#
console.log("---this script is currently a 'to-do' placeholder!---"); if [[ "x${OPTION}" != "x:" ]] && [[ "x${OPTION}" != "x?" ]] && [[ "${OPTARG}" = -* ]]; then
OPTARG="$OPTION" OPTION=":"
fi
#== manage options ==#
case "$OPTION" in
q)
QUIET_MODE=1
;;
: ) >&2 echo "${ME_NAME}: (FATAL) $OPTREF option requires a value" && echo -e "$ME_USAGE" && exit 1 ;;
? ) >&2 echo "${ME_NAME}: (FATAL) $OPTREF is an unknown option" && echo -e "$ME_USAGE" && exit 1 ;;
esac
done
shift $((${OPTIND} - 1))
################################################################################
## display welcome message
################################################################################
if [ "$QUIET_MODE" -ne "1" ]; then
echo "update-formats"
echo " (c) 2017 Doug Bird, All Rights Reserved."
echo " see README.md for licensing and other information"
echo " https://github.com/katmore/tld-enum#readme"
echo ""
echo " Updates the 'tlds.csv' file from iana.org and re-generates the native format files"
echo ""
fi
################################################################################
## run the 'generate-tlds-csv.js' helper
################################################################################
CUR_HELPER_LABEL="new 'tlds.csv'"
CUR_HELPER_CMD=generate-tlds-csv.js
echo -e "generate $CUR_HELPER_LABEL: started\n"
$HELPER_DIR/$CUR_HELPER_CMD -q
CMD_STATUS=$?
# terminate if helper failed
if [ "$CMD_STATUS" -ne "0" ]; then
>&2 echo "$ME_NAME: (FATAL) helper for $CUR_HELPER_LABEL failed ($CUR_HELPER_CMD exit status $CMD_STATUS)"
exit $CMD_STATUS
fi
echo -e "\ngenerate new $CUR_HELPER_LABEL: success"
################################################################################
## run the 'generate-php-tld-enum.php' helper
################################################################################
CUR_HELPER_LABEL="new PHP format files"
CUR_HELPER_CMD=generate-php-tld-enum.php
echo -e "generate $CUR_HELPER_LABEL: started\n"
$HELPER_DIR/$CUR_HELPER_CMD -q
CMD_STATUS=$?
# terminate if helper failed
if [ "$CMD_STATUS" -ne "0" ]; then
>&2 echo "$ME_NAME: (FATAL) helper for $CUR_HELPER_LABEL failed ($CUR_HELPER_CMD exit status $CMD_STATUS)"
exit $CMD_STATUS
fi
echo -e "\ngenerate new $CUR_HELPER_LABEL: success"
################################################################################
## run the 'generate-js-tld-enum.js' helper
################################################################################
CUR_HELPER_LABEL="new JavaScript format files"
CUR_HELPER_CMD=generate-js-tld-enum.js
echo -e "generate $CUR_HELPER_LABEL: started\n"
$HELPER_DIR/$CUR_HELPER_CMD -q
CMD_STATUS=$?
# terminate if helper failed
if [ "$CMD_STATUS" -ne "0" ]; then
>&2 echo "$ME_NAME: (FATAL) helper for $CUR_HELPER_LABEL failed ($CUR_HELPER_CMD exit status $CMD_STATUS)"
exit $CMD_STATUS
fi
echo -e "\ngenerate new $CUR_HELPER_LABEL: success"
################################################################################
## run the 'generate-json-tld-enum.js' helper
################################################################################
CUR_HELPER_LABEL="new JSON format files"
CUR_HELPER_CMD=generate-json-tld-enum.js
echo -e "generate $CUR_HELPER_LABEL: started\n"
$HELPER_DIR/$CUR_HELPER_CMD -q
CMD_STATUS=$?
# terminate if helper failed
if [ "$CMD_STATUS" -ne "0" ]; then
>&2 echo "$ME_NAME: (FATAL) helper for $CUR_HELPER_LABEL failed ($CUR_HELPER_CMD exit status $CMD_STATUS)"
exit $CMD_STATUS
fi
echo -e "\ngenerate new $CUR_HELPER_LABEL: success"

View File

@ -1,27 +1,38 @@
{ {
"name": "tld-enum", "name": "tld-enum",
"version": "1.0.4", "version": "1.0.4",
"description": "Lists of every ICANN TLD in formats that can be natively compiled in various language targets", "description": "Lists of every ICANN TLD in formats that can be natively compiled in various language targets",
"main": "formats/js/tld-enum.js", "main": "formats/js/tld-enum.js",
"bin": { "bin": {
"tld-enum": "generate-json-tld-enum.js" "tld-enum": "generate-json-tld-enum.js"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/katmore/tld-enum.git" "url": "git+https://github.com/katmore/tld-enum.git"
}, },
"author": "Doug Bird", "author": "Doug Bird",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/katmore/tld-enum/issues" "url": "https://github.com/katmore/tld-enum/issues"
}, },
"homepage": "https://github.com/katmore/tld-enum#readme", "homepage": "https://github.com/katmore/tld-enum#readme",
"dependencies": { "dependencies": {
"async-request": "^1.2.0", "async-request": "^1.2.0",
"cheerio": "^1.0.0-rc.2", "cheerio": "^1.0.0-rc.2",
"request": "^2.83.0" "commander": "^2.12.2",
} "country-data": "0.0.31",
"countryjs": "^1.8.0",
"csv-parse": "^2.0.0",
"csv-stringify": "^2.0.0",
"es6-promisify": "^5.0.0",
"fs": "0.0.1-security",
"fs-extra": "^5.0.0",
"md5-file": "^3.2.3",
"pathinfo": "^0.1.0",
"request": "^2.83.0",
"tmp": "0.0.33"
}
} }