-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.json
117 lines (117 loc) · 16.9 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
"name": "itr8",
"version": "0.4.10",
"description": "An experiment to create a unified interface such that the same reducers can be used in various contexts.",
"type": "module",
"// about main and types": "they are not pointing to dist/ folder because the prepare script copies everything to root after the build!!!",
"main": "index.js",
"types": "index.d.ts",
"browser": "itr8.min.js",
"// no files section !!!": "so we won't keep what's specified here, but instead remove what is specified in .npmignore",
"// files": [
"/dist"
],
"scripts": {
"find": "find . -path ./dist -prune -o -wholename './package.json' -prune -o -wholename './README.md' -o -wholename './LICENSE' -prune -o -print | less",
"preparetest": "echo $PWD/node_modules/itr8 | sed 's:^.*/node_modules/.*$':TRUE:g; [ `echo $PWD | sed 's:^.*/node_modules/.*$':TRUE:g` = 'TRUE' ] && echo true || echo false",
"// prepare 01": "(run when the package is installed as a dependency, BUT ALSO when you run 'npm install' without arguments locally in the project root)",
"// prepare 02": "Copy everything below dist/ to the root to make require('itr8/...') work (instead of require('itr8/dist/...'))",
"// prepare 03": "and then remove what is not necessary with an rm $( find ... ) command that will ",
"// prepare 04": "list all files that can be removed ()",
"// prepare 05": "OBSOLETE: and then remove what is not necessaryby specifying the unnecessary ones in .npmignore cfr. https://stackoverflow.com/questions/49858168/how-to-publish-typescript-modules-on-npm-without-dist-in-import and https://docs.npmjs.com/cli/v9/configuring-npm/package-json?v=true#files and also (for not running the postprepare script on a local npm install) https://github.com/nmccready/skip-npm-task/blob/master/index.js",
"// prepare 06": "CURRENT: removeUnneedeFiles() could have been written with find, but I use a simple ls (-A if you also want to remove hidden files, but not . and ..)",
"// prepare 07": " combined with inverse grep of some files we want to keep",
"// prepare 08": "we do an extra check to make sure we are being installed as a dependency: see if $PWD is under node_modules",
"// prepare 09": "[ \"${PWD#*/node_modules/}\" != \"${PWD}\" ] will return true if $PWD contains /node_modules/ cfr. https://stackoverflow.com/a/8811800",
"// prepare 10": "removed the check for || [ \"${PWD#*/node_modules/}\" = \"${PWD}\" ]",
"prepare": "removeUnneedeFiles() {\n ls -A | grep -E -v '^package.json|LICENSE|README.md|dist$' | while read F; do\n rm -rf \"$F\";\n done\n };\n echo $(pwd);\n if [ \"$( basename \"$(pwd)\" )\" = \"dist\" ];\n then\n echo \"[prepare] in dist folder, so I am assuming build has already run (like when prepare is being called as a part of npm publish)\";\n else\n npm run build && echo \"[itr8] $INIT_CWD =? $PWD\" && if [ \"$INIT_CWD\" = \"$PWD\" -o \"$INIT_CWD\" = '' ] ; then\n echo '[itr8 prepare] LOCAL INSTALL: not copying files under dist/ to root!!!';\n else\n echo '[itr8 prepare] NON local install (installed as dependency), so remove unneeded files & copy all files under dist/ to root folder' && removeUnneedeFiles && mv dist/* . && rmdir dist;\n fi\n fi",
"//build_mjs and build_cjs": "experiments building esm-modules inpired by https://styfle.dev/blog/es6-modules-today-with-typescript",
"build_mjs": "./node_modules/typescript/bin/tsc -d && mv dist/index.js dist/index.mjs",
"build_cjs": "./node_modules/typescript/bin/tsc -m commonjs",
"prebuild": "npm run clean",
"// about build": "Use tsconfig.prod.json which extends tsconfig.json but excludes building the tests and testUtils",
"build": "./node_modules/typescript/bin/tsc --project ./tsconfig.prod.json && ./node_modules/typescript/bin/tsc --project ./tsconfig.prod_cjs.json &&\n echo 'Adding ./dist_test_cjs/package.json without type: module, to make sure the js files in this directory are interpreted as CommonJS modules and not Ecmascript modules' &&\n echo '{ \"name\": \"itr8-cjs\" }' > ./dist/cjs/package.json",
"//postbuild (create bundle from js files)": " ( esbuild dist/index.js --format=esm --bundle --minify --tree-shaking=true --sourcemap --target=chrome100,firefox100,safari14,edge100 --outfile=dist/itr8.min.js)",
"postbuild": "( esbuild src/index.ts --format=esm --bundle --minify --tree-shaking=true --sourcemap --target=chrome100,firefox100,safari14,edge100 --outfile=dist/itr8.min.js )",
"//postbuild_old": "npm run builddocs",
"clean": "rm -rf ./dist ./dist_test ./dist_test_cjs ./docs",
"builddocs": "typedoc --options typedoc.cjs",
"postbuilddocs": "./optimize_generated_docs_for_git.sh; ./generate_sitemap_for_docs.sh; printf 'google-site-verification: google5ae8f564354feaad.html' > ./docs/google5ae8f564354feaad.html",
"echoForTest": "echo \"01 this is stdin\n02 So we can do some stream tests in the program\n03\n04\"",
"testOld": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 200 --node-option max-old-space-size=200 --require ts-node/register ./test/*.ts",
"testDebug": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 1000 --node-option max-old-space-size=300 --require ts-node/register $( find ./test ./src -iname '*.test.ts' -type f | sort )",
"//": "In summary, you should use a patch version for bug fixes, a minor version for backward-compatible feature additions, and a major version for breaking changes.",
"testPart": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 1000 --node-option max-old-space-size=300 --require ts-node/register $( find ./test ./src -iname '*.test.ts' -type f | sort | grep -v 'src/index' | grep -v 'parseJson' | grep -v 'transduce' | grep -v 'gzip' | grep 'parallel' )",
"testOnly": "testOnly() { [ \"$1\" = \"\" ] && echo \"Usage:\n npm run testOnly -- 'grepRegexToMatchTestFilename'\nExample to run the tests about itr8ToObject and the parallel operator:\n npm run testOnly -- 'itr8ToObject|parallel'\" >&2 && exit 1; npm run echoForTest --silent | c8 mocha --exit --timeout 1000 --node-option max-old-space-size=300 --require ts-node/register $( find ./test ./src -iname '*.test.ts' -type f | sort | grep -v 'src/index' | grep -E \"$1\" ); }; testOnly",
"//pretest": "npm run clean && mkdir -p ./dist && npm run build",
"pretest": "npm run prettier:fix",
"test": "MOCHA_CMD=\"mocha\"\n[ -z \"$SKIP_C8\" ] && MOCHA_CMD=\"c8 mocha\"\n\nnpm run echoForTest --silent | $MOCHA_CMD --exit --timeout 200 --require ts-node/esm $( find ./test ./src -iname '*.test.ts' -type f | sort )",
"//test": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 200 --node-option max-old-space-size=150 --require ts-node/register $( find ./test ./src -iname '*.test.ts' -type f -print | sort)",
"posttest": "npm run build",
"pretestCompiled": "rm -rf ./dist_test &&\n ./node_modules/typescript/bin/tsc --project ./tsconfig.test.json",
"testCompiled": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 200 $( find ./dist_test/test ./dist_test/src -iname '*.test.js' -type f | sort )",
"pretestCjsCompiled": "rm -rf ./dist_test_cjs &&\n ./node_modules/typescript/bin/tsc --project ./tsconfig.test_cjs.json &&\n echo 'Adding ./dist_test_cjs/package.json without type: module, to make sure the js files in this directory are interpreted as CommonJS modules and not Ecmascript modules' &&\n echo '{ \"name\": \"itr8-cjs\" }' > ./dist_test_cjs/package.json",
"testCjsCompiled": "npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 200 $( find ./dist_test_cjs/test ./dist_test_cjs/src -iname '*.test.js' -type f | sort )",
"// pretestInsideDocker": "rm -rf node_modules docs build package-lock.json && echo \"==== start npm install (using node $( node --version ) and npm $( npm --version ))\" && npm install --foreground-scripts=true",
"// testInsideDocker": "echo \"==== start EcmaScript Module mocha tests on node $( node --version )\" && \n npm run echoForTest --silent | ./node_modules/.bin/mocha --exit --timeout 5000 --node-option max-old-space-size=150 --require ts-node/register $( find ./test ./src -iname '*.test.ts' -type f -printf '%h\\t%p\\n' | sort | awk -F\"\\t\" '{print $2}' )",
"testInsideDocker": "echo \"==== start EcmaScript Module mocha tests on node $( node --version )\" &&\n npm run testCompiled &&\n echo \"==== Successfully finished EcmaScript Module mocha tests on node $( node --version )\"",
"// pretestCjsInsideDocker": "rm -rf node_modules docs build package-lock.json && echo \"==== start npm install (using node $( node --version ) and npm $( npm --version ))\" && npm install --foreground-scripts=true",
"testCjsInsideDocker": "echo \"==== start CommonJS mocha tests on node $( node --version )\" && \n npm run testCjsCompiled &&\n echo \"==== Successfully finished CommonJS mocha tests on node $( node --version )\"",
"testOnDocker": "testOnDocker() {\n NODEVERSIONS=$@;\n if [ \"$NODEVERSIONS\" = \"\" ]; then\n echo 'Error: pass node versions as argument';\n exit 1;\n fi\n (\n cd $( npm prefix )/test &&\n ( docker compose down --rmi=local --remove-orphans || true ) &&\n for NODEVERSION in $NODEVERSIONS; do\n echo && echo \"======== Running tests on node ${NODEVERSION} ========\" && echo;\n docker compose run itr8node${NODEVERSION}tests;\n EXITCODE=$?;\n echo;\n if [ ${EXITCODE} -eq 0 ]; then\n echo \"======== Tests on node ${NODEVERSION} were successful ========\";\n else\n echo \"======== Tests on node ${NODEVERSION} FAILED with exit code $EXITCODE ========\";\n echo;\n exit $EXITCODE;\n fi;\n done;\n )\n}\ntestOnDocker",
"prettier:fix": "npx prettier --write .",
"prettier:check": "npx prettier --check .",
"// to 'release' things, we need to use npm version": "npm version patch || npm version minor || npm version major",
"preversion": "if [ $( git symbolic-ref --short HEAD ) != 'main' ]; then echo '[version] Bumping the version should only be done on the main branch.' && exit 1; fi && npm run testOnDocker 14 16 18 20 22 && npm run build && npm run builddocs && git add -f dist/ docs/",
"version": "NEW_VERSION=$(node -p 'require(\"./package.json\").version')\nRELEASEDATESTR=\"$(date +'%Y-%m-%d')\"\nCHANGELOG_FILENAME=\"CHANGELOG.md\"\n\nCHANGELOG_SECTION=\"## version $NEW_VERSION ($RELEASEDATESTR)\"\n\nif [ \"$( grep \"$CHANGELOG_SECTION\" ${CHANGELOG_FILENAME} )\" = '' ]; then\n echo \"[version] Make sure the new version ($NEW_VERSION) has release notes in ${CHANGELOG_FILENAME} and the date matches today.\" &&\n echo &&\n echo \"The header should look like:\" &&\n echo \"$CHANGELOG_SECTION\" &&\n echo &&\n git reset &&\n exit 1\nfi\n\n\nif [ $( git symbolic-ref --short HEAD ) != 'main' ]; then\n echo '[version] Bumping the version should only be done on the main branch.' && exit 1;\nfi\n# && NEW_VERSION=$(node -p 'require(\"./package.json\").version')\n# && echo \"Commit a new version v${NEW_VERSION}\" && git commit -m \"Bump version to v${NEW_VERSION}\" && echo \"Tag the new version v${NEW_VERSION}\" && echo git tag --annotate '\"v${NEW_VERSION}\"' --message '\"Version v${NEW_VERSION}\"' preversion",
"postversion": "if [ $( git symbolic-ref --short HEAD ) != 'main' ]; then echo '[version] Bumping the version should only be done on the main branch.' && exit 1; fi && git push && git push --tags # && rm -rf dist/ docs/",
"// release": "use this one when you want to do a new release (to increase the version, add a tag, etc. AND publish to npm)!!!",
"release": "release() {\n echo \"[release] $1\"; [ \"$1\" != 'major' ] && [ \"$1\" != 'minor' ] && [ \"$1\" != 'patch' ] && echo \"We need 1 parameter with value major|minor|patch instead of '$1'.\nExample: npm run release -- minor\" && exit 1;\n npm version $1 --message \"Version %s\n\nChanges:\n\n\" &&\n cp package.json dist/ && ( printf 'PLEASE ENTER OTP for publishing to npm (leave empty if not needed): ' && read NPM_OTP && npm publish --registry https://registry.npmjs.org/ ${NPM_OTP:+--otp $NPM_OTP} ./dist || npm run print:npmPublishFailed )\n }\n\nrelease",
"print:npmPublishFailed": "printf \"\\033[1m\\033[31m%s\\n\\033[0m\" \"NPM PUBLISH FAILED.\nDo not run 'npm run release' again but instead figure out why it failed and retry\n npm publish --registry https://registry.npmjs.org/ ./dist\"",
"// publish": "we will publish the dist folder only, so first we need to copy the package.json into the dist folder, then cd into it and only then run npm publish !!!",
"// publish 02": "npm publish will run prepublishOnly, prepack, prepare, postpack, publish, postpublish",
"prepack": "if [ \"$(basename \"$(pwd)\")\" != \"dist\" ] && [ -f package.json ];\n then echo \"\n********************************************************************************\n[publish] DO NOT RUN npm publish from the project's root, but instead from inside the /dist folder\n********************************************************************************\n\" && exit 1;\n fi;\n if [ $( git symbolic-ref --short HEAD ) != 'main' ];\n then echo '\n********************************************************************************\n[publish] Publishing to npm should only be done on the main branch.\n********************************************************************************\n';\n fi;\n cp ../README.md ../LICENSE . ;\n",
"// postpack": "ls ../;\n",
"gitDiff": "gitdiff() {\n echo 'git diff but exclude irrelevant directories like dist/ and docs/' && git diff \"$@\" -- . ':!dist/' ':!docs/'\n}\ngitdiff",
"pkg:update_script": "\npkg_update_script() {\n # Check if a key is provided\n if [ -z \"$1\" ]; then\n printf \"\nThis script allows you to set one of the scripts in package.json by using VS Code editor (makes it easier to edit multiline scripts).\nIf the key exists, a tmp file with the current contents will be opened that you can edit, save and close.\nIf the key does not exist, you'll be asked if you want to add the key.\nThe altered (or newly created) contents will be put in the package.json.\n\nUsage: $0 <key>\n\n$@\nexit 1\n\n\"\n fi\n\n # Define the key to be edited\n KEY=\"scripts.$1\"\n\n # Get the existing value\n # EXISTING_VALUE=$(npm pkg get $KEY | jq -r .) # returns {} if not found\n # EXISTING_VALUE=$(jq -r \".$KEY\" package.json) # returns null if not found\n ## this version only depends on node, which should always be available in a node project :)\n EXISTING_VALUE=$(node -p \"require('./package.json').$KEY\") # returns undefined if not found\n\n # Check if the property exists\n if [ \"$EXISTING_VALUE\" = \"undefined\" ]; then\n read -p \"Property '$KEY' not found. Are you sure you want to create it? (y/N): \" CONFIRM\n if [ \"$CONFIRM\" != \"y\" ]; then\n echo \"Aborting.\"\n exit 1\n fi\n EXISTING_VALUE=\"\"\n fi\n\n # Write the existing value to a temporary file\n TEMP_FILE=\"$(mktemp).sh\"\n echo \"$EXISTING_VALUE\" > \"$TEMP_FILE\"\n\n # Open the file with VS Code and wait for it to close\n echo \"Opening $KEY in VS Code...\"\n echo \"After closing the editor the script will continue, and the updated value will be written to package.json\"\n code --wait \"$TEMP_FILE\"\n\n # Read the updated value from the file\n UPDATED_VALUE=$(cat \"$TEMP_FILE\")\n\n # Update the package.json with the new value\n npm pkg set $KEY=\"$UPDATED_VALUE\"\n\n # Clean up the temporary file\n rm \"$TEMP_FILE\"\n\n echo \"Updated $KEY in package.json\"\n\n}\n\n# !!! no final newline if we want to pass the arguments to the funtion !!!\npkg_update_script",
"benchmark": "(\n npm run build\n cd benchmarks\n # npm install only if node_modules is not present\n if [ ! -d \"node_modules\" ]; then\n npm install\n fi\n npm run test\n)"
},
"keywords": [],
"author": "Frederik Tilkin",
"license": "ISC",
"homepage": "https://mrft.github.io/itr8",
"repository": {
"type": "git",
"url": "git+https://github.com/mrft/itr8.git"
},
"bugs": {
"url": "https://github.com/mrft/itr8/issues"
},
"devDependencies": {
"@knodes/typedoc-plugin-pages": "^0.23.4",
"@sinonjs/fake-timers": "^11.0.0",
"@streamparser/json": "^0.0.6",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.1",
"@types/node": "^18.11.17",
"@types/sinon": "^10.0.15",
"@types/sinonjs__fake-timers": "^8.1.2",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"c8": "^10.1.2",
"chai": "^4.3.6",
"esbuild": "^0.18.9",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"mocha": "^9.2.2",
"rxjs": "^7.5.5",
"sinon": "^18.0.0",
"transducers-js": "^0.4.174",
"ts-node": "^10.9.2",
"typedoc": "^0.23.28",
"typescript": "^4.9.5"
},
"peerDependencies": {
"@streamparser/json": "^0.0.6"
}
}