Skip to content

Instantly share code, notes, and snippets.

@wolfram77
Last active September 24, 2018 10:14
Show Gist options
  • Save wolfram77/7727b8e68b733bc958169f8dad182468 to your computer and use it in GitHub Desktop.
Save wolfram77/7727b8e68b733bc958169f8dad182468 to your computer and use it in GitHub Desktop.
start cmd /c enpm clone string-asc -a -r extra-string/asc
start cmd /c enpm clone string-chr -a -r extra-string/chr
start cmd /c enpm clone string-commoninfix -a -r extra-string/common-infix
start cmd /c enpm clone string-commonprefix -a -r extra-string/common-prefix
start cmd /c enpm clone string-commonsuffix -a -r extra-string/common-suffix
start cmd /c enpm clone string-commontransfix -a -r extra-string/common-transfix
start cmd /c enpm clone string-dameraulevenshteindistance -a -r extra-string/damerau-levenshtein-distance
start cmd /c enpm clone string-digits -a -r extra-string/digits
start cmd /c enpm clone string-entries -a -r extra-string/entries
call enpm clone string-euclideandistance -a -r extra-string/euclidean-distance
start cmd /c enpm clone string-every -a -r extra-string/every
start cmd /c enpm clone string-filter -a -r extra-string/filter
start cmd /c enpm clone string-find -a -r extra-string/find
start cmd /c enpm clone string-findindex -a -r extra-string/find-index
start cmd /c enpm clone string-from -a -r extra-string/from
start cmd /c enpm clone string-hammingdistance -a -r extra-string/hamming-distance
start cmd /c enpm clone string-hexdigits -a -r extra-string/hex-digits
start cmd /c enpm clone string-isx -a -r extra-string/is
start cmd /c enpm clone string-jaccarddistance -a -r extra-string/jaccard-distance
call enpm clone string-jaccardindex -a -r extra-string/jaccard-index
start cmd /c enpm clone string-jarodistance -a -r extra-string/jaro-distance
start cmd /c enpm clone string-jarowinklerdistance -a -r extra-string/jaro-winkler-distance
start cmd /c enpm clone string-keys -a -r extra-string/keys
start cmd /c enpm clone string-left -a -r extra-string/left
start cmd /c enpm clone string-letters -a -r extra-string/letters
start cmd /c enpm clone string-levenshteindistance -a -r extra-string/levenshtein-distance
start cmd /c enpm clone string-localecompare -a -r extra-string/locale-compare
start cmd /c enpm clone string-lowercase -a -r extra-string/lower-case
start cmd /c enpm clone string-mapreplace -a -r extra-string/map-replace
call enpm clone string-mapreplaceprefix -a -r extra-string/map-replace-prefix
start cmd /c enpm clone string-mapreplacesuffix -a -r extra-string/map-replace-suffix
start cmd /c enpm clone string-matchingngramcount -a -r extra-string/matching-ngram-count
start cmd /c enpm clone string-matchingngrams -a -r extra-string/matching-ngrams
start cmd /c enpm clone string-mid -a -r extra-string/mid
start cmd /c enpm clone string-ngrams -a -r extra-string/ngrams
start cmd /c enpm clone string-objectreplace -a -r extra-string/object-replace
start cmd /c enpm clone string-objectreplaceprefix -a -r extra-string/object-replace-prefix
start cmd /c enpm clone string-objectreplacesuffix -a -r extra-string/object-replace-suffix
start cmd /c enpm clone string-octdigits -a -r extra-string/oct-digits
call enpm clone string-of -a -r extra-string/of
start cmd /c enpm clone string-printable -a -r extra-string/printable
start cmd /c enpm clone string-punctuation -a -r extra-string/punctuation
start cmd /c enpm clone string-reduceright -a -r extra-string/reduce-right
start cmd /c enpm clone string-replaceprefix -a -r extra-string/replace-prefix
start cmd /c enpm clone string-replacesuffix -a -r extra-string/replace-suffix
start cmd /c enpm clone string-right -a -r extra-string/right
start cmd /c enpm clone string-sorensendicedistance -a -r extra-string/sorensen-dice-distance
start cmd /c enpm clone string-sorensendiceindex -a -r extra-string/sorensen-dice-index
start cmd /c enpm clone string-space -a -r extra-string/space
call enpm clone string-symbolat -a -r extra-string/symbol-at
start cmd /c enpm clone string-tobaseline -a -r extra-string/to-baseline
start cmd /c enpm clone string-tocamelcase -a -r extra-string/to-camel-case
start cmd /c enpm clone string-tosnakecase -a -r extra-string/to-snake-case
start cmd /c enpm clone string-tosubscript -a -r extra-string/to-subscript
start cmd /c enpm clone string-tosuperscript -a -r extra-string/to-superscript
start cmd /c enpm clone string-totitlecase -a -r extra-string/to-title-case
start cmd /c enpm clone string-tverskydistance -a -r extra-string/tversky-distance
start cmd /c enpm clone string-tverskyindex -a -r extra-string/tversky-index
start cmd /c enpm clone string-uncommoninfix -a -r extra-string/uncommon-infix
call enpm clone string-uppercase -a -r extra-string/uppercase
start cmd /c enpm clone string-values -a -r extra-string/values
start cmd /c enpm clone string-whitespace -a -r extra-string/whitespace
start cmd /c node ./deprecate string-asc "@extra-string/asc"
start cmd /c node ./deprecate string-chr "@extra-string/chr"
start cmd /c node ./deprecate string-commoninfix "@extra-string/common-infix"
start cmd /c node ./deprecate string-commonprefix "@extra-string/common-prefix"
start cmd /c node ./deprecate string-commonsuffix "@extra-string/common-suffix"
start cmd /c node ./deprecate string-commontransfix "@extra-string/common-transfix"
start cmd /c node ./deprecate string-dameraulevenshteindistance "@extra-string/damerau-levenshtein-distance"
start cmd /c node ./deprecate string-digits "@extra-string/digits"
start cmd /c node ./deprecate string-entries "@extra-string/entries"
call node ./deprecate string-euclideandistance "@extra-string/euclidean-distance"
start cmd /c node ./deprecate string-every "@extra-string/every"
start cmd /c node ./deprecate string-filter "@extra-string/filter"
start cmd /c node ./deprecate string-find "@extra-string/find"
start cmd /c node ./deprecate string-findindex "@extra-string/find-index"
start cmd /c node ./deprecate string-from "@extra-string/from"
start cmd /c node ./deprecate string-hammingdistance "@extra-string/hamming-distance"
start cmd /c node ./deprecate string-hexdigits "@extra-string/hex-digits"
start cmd /c node ./deprecate string-isx "@extra-string/is"
start cmd /c node ./deprecate string-jaccarddistance "@extra-string/jaccard-distance"
call node ./deprecate string-jaccardindex "@extra-string/jaccard-index"
start cmd /c node ./deprecate string-jarodistance "@extra-string/jaro-distance"
start cmd /c node ./deprecate string-jarowinklerdistance "@extra-string/jaro-winkler-distance"
start cmd /c node ./deprecate string-keys "@extra-string/keys"
start cmd /c node ./deprecate string-left "@extra-string/left"
start cmd /c node ./deprecate string-letters "@extra-string/letters"
start cmd /c node ./deprecate string-levenshteindistance "@extra-string/levenshtein-distance"
start cmd /c node ./deprecate string-localecompare "@extra-string/locale-compare"
start cmd /c node ./deprecate string-lowercase "@extra-string/lower-case"
start cmd /c node ./deprecate string-mapreplace "@extra-string/map-replace"
call node ./deprecate string-mapreplaceprefix "@extra-string/map-replace-prefix"
start cmd /c node ./deprecate string-mapreplacesuffix "@extra-string/map-replace-suffix"
start cmd /c node ./deprecate string-matchingngramcount "@extra-string/matching-ngram-count"
start cmd /c node ./deprecate string-matchingngrams "@extra-string/matching-ngrams"
start cmd /c node ./deprecate string-mid "@extra-string/mid"
start cmd /c node ./deprecate string-ngrams "@extra-string/ngrams"
start cmd /c node ./deprecate string-objectreplace "@extra-string/object-replace"
start cmd /c node ./deprecate string-objectreplaceprefix "@extra-string/object-replace-prefix"
start cmd /c node ./deprecate string-objectreplacesuffix "@extra-string/object-replace-suffix"
start cmd /c node ./deprecate string-octdigits "@extra-string/oct-digits"
call node ./deprecate string-of "@extra-string/of"
start cmd /c node ./deprecate string-printable "@extra-string/printable"
start cmd /c node ./deprecate string-punctuation "@extra-string/punctuation"
start cmd /c node ./deprecate string-reduceright "@extra-string/reduce-right"
start cmd /c node ./deprecate string-replaceprefix "@extra-string/replace-prefix"
start cmd /c node ./deprecate string-replacesuffix "@extra-string/replace-suffix"
start cmd /c node ./deprecate string-right "@extra-string/right"
start cmd /c node ./deprecate string-sorensendicedistance "@extra-string/sorensen-dice-distance"
start cmd /c node ./deprecate string-sorensendiceindex "@extra-string/sorensen-dice-index"
start cmd /c node ./deprecate string-space "@extra-string/space"
call node ./deprecate string-symbolat "@extra-string/symbol-at"
start cmd /c node ./deprecate string-tobaseline "@extra-string/to-baseline"
start cmd /c node ./deprecate string-tocamelcase "@extra-string/to-camel-case"
start cmd /c node ./deprecate string-tosnakecase "@extra-string/to-snake-case"
start cmd /c node ./deprecate string-tosubscript "@extra-string/to-subscript"
start cmd /c node ./deprecate string-tosuperscript "@extra-string/to-superscript"
start cmd /c node ./deprecate string-totitlecase "@extra-string/to-title-case"
start cmd /c node ./deprecate string-tverskydistance "@extra-string/tversky-distance"
start cmd /c node ./deprecate string-tverskyindex "@extra-string/tversky-index"
start cmd /c node ./deprecate string-uncommoninfix "@extra-string/uncommon-infix"
call node ./deprecate string-uppercase "@extra-string/uppercase"
start cmd /c node ./deprecate string-values "@extra-string/values"
start cmd /c node ./deprecate string-whitespace "@extra-string/whitespace"
const path = require('path');
const cp = require('child_process');
const fs = require('fs');
const os = require('os');
const A = process.argv;
var src = A[2], dst = A[3];
var pth = path.join(process.cwd(), src);
cp.execSync(`enpm clone ${src}`, {stdio: [0, 1, 2]});
var rdmf = path.join(pth, 'README.md');
var rdm = fs.readFileSync(rdmf, 'utf8');
var rdmp = rdm.split(os.EOL);
rdmp.splice(2, 0, `> NOTE: [${src}](https://www.npmjs.com/package/${src}) was renamed to [${dst}](https://www.npmjs.com/package/${dst}).`);
rdm = rdmp.join(os.EOL);
fs.writeFileSync(rdmf, rdm);
cp.execSync(`enpm push "deprecate package"`, {stdio: [0, 1, 2], cwd: pth});
const stats = require('download-stats');
const Npm = require('npm-api');
function downloads(pkgs) {
var z = [];
return new Promise((fres, frej) => {
for(var p of pkgs) {
stats.get.lastMonth(p, (err, res) => {
if(err) return frej(err);
z.push(res);
if(z.length===pkgs.length) fres(z);
});
}
});
};
async function pkgDownloads() {
var npm = new Npm();
var pkgs = await npm.maintainer('wolfram77').repos();
var rank = await downloads(pkgs);
rank.sort((a, b) => a.downloads>b.downloads? -1:(a.downloads<b.downloads? 1:0));
for(var p of rank)
console.log(p.downloads, p.package);
};
async function pkgSearch(pat) {
var npm = new Npm();
var pkgs = await npm.maintainer('wolfram77').repos();
for(var p of pkgs)
if(pat.test(p)) console.log(p);
};
pkgSearch(/^string-/);
start cmd /c tov1 "asc"
start cmd /c tov1 "chr"
start cmd /c tov1 "common-infix"
start cmd /c tov1 "common-prefix"
start cmd /c tov1 "common-suffix"
start cmd /c tov1 "common-transfix"
start cmd /c tov1 "damerau-levenshtein-distance"
start cmd /c tov1 "digits"
start cmd /c tov1 "entries"
call tov1 "euclidean-distance"
start cmd /c tov1 "every"
start cmd /c tov1 "filter"
start cmd /c tov1 "find"
start cmd /c tov1 "find-index"
start cmd /c tov1 "from"
start cmd /c tov1 "hamming-distance"
start cmd /c tov1 "hex-digits"
start cmd /c tov1 "is"
start cmd /c tov1 "jaccard-distance"
call tov1 "jaccard-index"
start cmd /c tov1 "jaro-distance"
start cmd /c tov1 "jaro-winkler-distance"
start cmd /c tov1 "keys"
start cmd /c tov1 "left"
start cmd /c tov1 "letters"
start cmd /c tov1 "levenshtein-distance"
start cmd /c tov1 "locale-compare"
start cmd /c tov1 "lower-case"
start cmd /c tov1 "map-replace"
call tov1 "map-replace-prefix"
start cmd /c tov1 "map-replace-suffix"
start cmd /c tov1 "matching-ngram-count"
start cmd /c tov1 "matching-ngrams"
start cmd /c tov1 "mid"
start cmd /c tov1 "ngrams"
start cmd /c tov1 "object-replace"
start cmd /c tov1 "object-replace-prefix"
start cmd /c tov1 "object-replace-suffix"
start cmd /c tov1 "oct-digits"
call tov1 "of"
start cmd /c tov1 "printable"
start cmd /c tov1 "punctuation"
start cmd /c tov1 "reduce-right"
start cmd /c tov1 "replace-prefix"
start cmd /c tov1 "replace-suffix"
start cmd /c tov1 "right"
start cmd /c tov1 "sorensen-dice-distance"
start cmd /c tov1 "sorensen-dice-index"
start cmd /c tov1 "space"
call tov1 "symbol-at"
start cmd /c tov1 "to-baseline"
start cmd /c tov1 "to-camel-case"
start cmd /c tov1 "to-snake-case"
start cmd /c tov1 "to-subscript"
start cmd /c tov1 "to-superscript"
start cmd /c tov1 "to-title-case"
start cmd /c tov1 "tversky-distance"
start cmd /c tov1 "tversky-index"
start cmd /c tov1 "uncommon-infix"
call tov1 "uppercase"
start cmd /c tov1 "values"
start cmd /c tov1 "whitespace"
@echo off
cd "%1"
call enpm push -3 "to v1"
call enpm push "update"
cd ..
const Octokit = require('@octokit/rest');
const fs = require('fs');
const E = process.env;
const ORG = 'extra-string';
var octokit = new Octokit({
headers: {accept: 'application/vnd.github.mister-fantastic-preview+json'}
});
octokit.authenticate({
type: 'basic',
username: E['GITHUB_USERNAME'],
password: E['GITHUB_PASSWORD']
});
async function main() {
var repos = await octokit.repos.getForOrg({org: ORG, per_page: 100});
for(var r of repos.data) {
console.log(r.name);
var topics = ORG.split('-');
topics.push.apply(topics, r.name.split(/\W/g));
topics.push('nodejs', 'merferry');
octokit.repos.edit({owner: ORG, repo: r.name, name: r.name, homepage: `https://www.npmjs.com/package/@${ORG}/${r.name}`});
octokit.repos.replaceTopics({owner: ORG, repo: r.name, names: topics});
// octokit.repos.editPages({owner: ORG, repo: r.name, cname: null, source: 'master'});
}
};
main();
const path = require('path');
const cp = require('child_process');
const fs = require('fs');
const os = require('os');
// Global variables.
const IGNORE = new Set(['0dlcount', '0push']);
const BANNER = '[![extra-string](https://i.imgur.com/y4YVIau.jpg)](https://www.npmjs.com/package/extra-string)';
function main() {
for(var de of fs.readdirSync('.', {withFileTypes: true})) {
if(!de.isDirectory() || IGNORE.has(de.name)) continue;
var nam = de.name, pth = path.join(process.cwd(), nam);
// cp.execSync('git reset --hard', {cwd: pth, stdio: [0, 1, 2]});
// continue;
// cp.execSync('git pull', {cwd: pth, stdio: [0, 1, 2]});
try {
var pkgf = path.join(pth, 'package.json');
var pkg = JSON.parse(fs.readFileSync(pkgf, 'utf8'));
var rep = cp.execSync('git config --get remote.origin.url', {cwd: pth}).toString().replace('\n', '');
var namo = pkg.name;
pkg.name = `@extra-string/${nam}`;
pkg.keywords.unshift('extra');
pkg.keywords.push('merferry');
pkg.repository = {type: 'git', url: `git+${rep}.git`};
pkg.bugs = {url: `${rep}/issues`};
pkg.homepage = `${rep}#readme`;
fs.writeFileSync(pkgf, JSON.stringify(pkg, null, 2).replace(/\n/g, os.EOL)+os.EOL);
var rdmf = path.join(pth, 'README.md');
var rdm = fs.readFileSync(rdmf, 'utf8');
var rdms = rdm.split(os.EOL);
rdms.splice(0, 4);
rdm = rdms.join(os.EOL);
rdm = rdm.replace(namo, pkg.name);
rdm = rdm.replace('```'+os.EOL+os.EOL, '```'+os.EOL+os.EOL+os.EOL+BANNER+os.EOL);
fs.writeFileSync(rdmf, rdm);
cp.execSync(`cp _config.yml ${nam}/.`, {stdio: [0, 1, 2]});
cp.execSync(`cp .npmignore ${nam}/.`, {stdio: [0, 1, 2]});
cp.execSync(`cp LICENSE ${nam}/.`, {stdio: [0, 1, 2]});
}
catch(e) { console.error(e); }
console.log(nam);
}
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment