From c010aaeaa36bb9da70076e7d93ad14e9f5d7f854 Mon Sep 17 00:00:00 2001 From: Gorka Date: Fri, 13 Oct 2017 10:39:32 +0200 Subject: [PATCH 1/6] Add script to transpile (babel) and minify (uglify v3) a given list of scripts Add correct file execute permissions --- packages/thicket-webapp/package.json | 4 +- packages/thicket-webapp/scripts/hack-build.sh | 232 ++++++++++++++++++ .../thicket-webapp/scripts/hack-source.sh | 7 + packages/thicket-webapp/yarn.lock | 66 ++++- 4 files changed, 306 insertions(+), 3 deletions(-) create mode 100755 packages/thicket-webapp/scripts/hack-build.sh create mode 100755 packages/thicket-webapp/scripts/hack-source.sh diff --git a/packages/thicket-webapp/package.json b/packages/thicket-webapp/package.json index 8f8005c..32db31d 100644 --- a/packages/thicket-webapp/package.json +++ b/packages/thicket-webapp/package.json @@ -43,6 +43,8 @@ "npm": "5.4.2" }, "devDependencies": { - "surge": "^0.19.0" + "babel-cli": "^6.26.0", + "surge": "^0.19.0", + "uglify-es": "^3.1.3" } } diff --git a/packages/thicket-webapp/scripts/hack-build.sh b/packages/thicket-webapp/scripts/hack-build.sh new file mode 100755 index 0000000..202c3f6 --- /dev/null +++ b/packages/thicket-webapp/scripts/hack-build.sh @@ -0,0 +1,232 @@ +. ./scripts/hack-source.sh + +for file in \ + "borc/src/decoder.js" \ + "borc/src/diagnose.js" \ + "borc/src/encoder.js" \ + "borc/src/simple.js" \ + "borc/src/tagged.js" \ + "borc/src/utils.js" \ + "datastore-core/src/keytransform.js" \ + "datastore-core/src/mount.js" \ + "datastore-core/src/namespace.js" \ + "datastore-core/src/shard-readme.js" \ + "datastore-core/src/shard.js" \ + "datastore-core/src/sharding.js" \ + "datastore-core/src/tiered.js" \ + "datastore-level/src/index.js" \ + "hyperdiff/lib/index.js" \ + "interface-connection/src/connection.js" \ + "interface-datastore/src/key.js" \ + "interface-datastore/src/memory.js" \ + "interface-datastore/src/utils.js" \ + "ipfs-bitswap/src/decision-engine/index.js" \ + "ipfs-bitswap/src/decision-engine/ledger.js" \ + "ipfs-bitswap/src/index.js" \ + "ipfs-bitswap/src/network.js" \ + "ipfs-bitswap/src/notifications.js" \ + "ipfs-bitswap/src/types/message/entry.js" \ + "ipfs-bitswap/src/types/message/index.js" \ + "ipfs-bitswap/src/types/message/message.proto.js" \ + "ipfs-bitswap/src/types/wantlist/entry.js" \ + "ipfs-bitswap/src/types/wantlist/index.js" \ + "ipfs-bitswap/src/utils.js" \ + "ipfs-bitswap/src/want-manager/index.js" \ + "ipfs-bitswap/src/want-manager/msg-queue.js" \ + "ipfs-block-service/src/index.js" \ + "ipfs-block/node_modules/cids/src/index.js" \ + "ipfs-block/src/index.js" \ + "ipfs-pubsub-room/src/connection.js" \ + "ipfs-pubsub-room/src/encoding.js" \ + "ipfs-pubsub-room/src/index.js" \ + "ipfs-repo/src/api-addr.js" \ + "ipfs-repo/src/blockstore.js" \ + "ipfs-repo/src/config.js" \ + "ipfs-repo/src/index.js" \ + "ipfs-repo/src/lock-memory.js" \ + "ipfs-repo/src/version.js" \ + "ipfs-unixfs-engine/src/builder/balanced/balanced-reducer.js" \ + "ipfs-unixfs-engine/src/builder/builder.js" \ + "ipfs-unixfs-engine/src/builder/create-build-stream.js" \ + "ipfs-unixfs-engine/src/builder/flat/index.js" \ + "ipfs-unixfs-engine/src/builder/reduce.js" \ + "ipfs-unixfs-engine/src/builder/trickle/trickle-reducer.js" \ + "ipfs-unixfs-engine/src/chunker/fixed-size.js" \ + "ipfs-unixfs-engine/src/hamt/bucket.js" \ + "ipfs-unixfs-engine/src/exporter/clean-multihash.js" \ + "ipfs-unixfs-engine/src/exporter/dir-flat.js" \ + "ipfs-unixfs-engine/src/exporter/dir-hamt-sharded.js" \ + "ipfs-unixfs-engine/src/exporter/file.js" \ + "ipfs-unixfs-engine/src/exporter/index.js" \ + "ipfs-unixfs-engine/src/exporter/object.js" \ + "ipfs-unixfs-engine/src/hamt/bucket.js" \ + "ipfs-unixfs-engine/src/hamt/consumable-buffer.js" \ + "ipfs-unixfs-engine/src/hamt/consumable-hash.js" \ + "ipfs-unixfs-engine/src/importer/dir-flat.js" \ + "ipfs-unixfs-engine/src/importer/dir-sharded.js" \ + "ipfs-unixfs-engine/src/importer/dir.js" \ + "ipfs-unixfs-engine/src/importer/flat-to-shard.js" \ + "ipfs-unixfs-engine/src/importer/index.js" \ + "ipfs-unixfs-engine/src/importer/tree-builder.js" \ + "ipfs-unixfs/src/index.js" \ + "ipfs-unixfs/src/unixfs.proto.js" \ + "ipfs/src/core/boot.js" \ + "ipfs/src/core/components/bitswap.js" \ + "ipfs/src/core/components/block.js" \ + "ipfs/src/core/components/bootstrap.js" \ + "ipfs/src/core/components/config.js" \ + "ipfs/src/core/components/dag.js" \ + "ipfs/src/core/components/dht.js" \ + "ipfs/src/core/components/files.js" \ + "ipfs/src/core/components/id.js" \ + "ipfs/src/core/components/init.js" \ + "ipfs/src/core/components/is-online.js" \ + "ipfs/src/core/components/libp2p.js" \ + "ipfs/src/core/components/object.js" \ + "ipfs/src/core/components/ping.js" \ + "ipfs/src/core/components/pre-start.js" \ + "ipfs/src/core/components/pubsub.js" \ + "ipfs/src/core/components/repo.js" \ + "ipfs/src/core/components/start.js" \ + "ipfs/src/core/components/stop.js" \ + "ipfs/src/core/components/swarm.js" \ + "ipfs/src/core/components/version.js" \ + "ipfs/src/core/index.js" \ + "ipfs/src/core/runtime/libp2p-browser.js" \ + "ipfs/src/core/runtime/repo-browser.js" \ + "ipfs/src/core/state.js" \ + "ipld-dag-cbor/src/resolver.js" \ + "ipld-dag-cbor/src/util.js" \ + "ipld-dag-pb/src/dag-link/index.js" \ + "ipld-dag-pb/src/dag-link/index.js" \ + "ipld-dag-pb/src/dag-node/create.js" \ + "ipld-dag-pb/src/dag-node/index.js" \ + "ipld-dag-pb/src/dag-node/rmLink.js" \ + "ipld-dag-pb/src/dag-node/util.js" \ + "ipld-dag-pb/src/dag.proto.js" \ + "ipld-dag-pb/src/resolver.js" \ + "ipld-dag-pb/src/util.js" \ + "ipld-eth-star/eth-block-list/index.js" \ + "ipld-eth-star/util/createIsLink.js" \ + "ipld-eth-star/util/createResolver.js" \ + "ipld-eth-star/util/createTrieResolver.js" \ + "ipld-eth-star/util/createUtil.js" \ + "ipld-eth-star/util/toIpfsBlock.js" \ + "ipld-git/src/resolver.js" \ + "ipld-git/src/util.js" \ + "ipld-git/src/util/commit.js" \ + "ipld-git/src/util/tag.js" \ + "ipld-git/src/util/tree.js" \ + "ipld-git/src/util/util.js" \ + "ipld-resolver/src/index.js" \ + "libp2p-crypto-secp256k1/src/crypto.js" \ + "libp2p-crypto-secp256k1/src/index.js" \ + "libp2p-crypto/src/aes/index.js" \ + "libp2p-crypto/src/hmac/index-browser.js" \ + "libp2p-crypto/src/keys/ecdh-browser.js" \ + "libp2p-crypto/src/keys/ed25519-class.js" \ + "libp2p-crypto/src/keys/ed25519.js" \ + "libp2p-crypto/src/keys/ephemeral-keys.js" \ + "libp2p-crypto/src/keys/index.js" \ + "libp2p-crypto/src/keys/key-stretcher.js" \ + "libp2p-crypto/src/keys/keys.proto.js" \ + "libp2p-crypto/src/keys/rsa-browser.js" \ + "libp2p-crypto/src/keys/rsa-class.js" \ + "libp2p-crypto/src/nodeify.js" \ + "libp2p-crypto/src/util.js" \ + "libp2p-crypto/src/webcrypto.js" \ + "libp2p-floodsub/src/index.js" \ + "libp2p-floodsub/src/message/rpc.proto.js" \ + "libp2p-floodsub/src/message/topic-descriptor.proto.js" \ + "libp2p-floodsub/src/peer.js" \ + "libp2p-floodsub/src/utils.js" \ + "libp2p-identify/src/dialer.js" \ + "libp2p-identify/src/listener.js" \ + "libp2p-identify/src/message.js" \ + "libp2p-multiplex/src/index.js" \ + "libp2p-multiplex/src/muxer.js" \ + "libp2p-ping/src/handler.js" \ + "libp2p-ping/src/ping.js" \ + "libp2p-ping/src/util.js" \ + "libp2p-railing/src/index.js" \ + "libp2p-secio/src/etm.js" \ + "libp2p-secio/src/handshake/crypto.js" \ + "libp2p-secio/src/handshake/exchange.js" \ + "libp2p-secio/src/handshake/finish.js" \ + "libp2p-secio/src/handshake/index.js" \ + "libp2p-secio/src/handshake/propose.js" \ + "libp2p-secio/src/handshake/secio.proto.js" \ + "libp2p-secio/src/index.js" \ + "libp2p-secio/src/state.js" \ + "libp2p-secio/src/support.js" \ + "libp2p-swarm/src/connection.js" \ + "libp2p-swarm/src/dial.js" \ + "libp2p-swarm/src/get-peer-info.js" \ + "libp2p-swarm/src/index.js" \ + "libp2p-swarm/src/limit-dialer/index.js" \ + "libp2p-swarm/src/limit-dialer/queue.js" \ + "libp2p-swarm/src/plaintext.js" \ + "libp2p-swarm/src/protocol-muxer.js" \ + "libp2p-swarm/src/transport.js" \ + "libp2p-webrtc-star/src/index.js" \ + "libp2p-webrtc-star/src/utils.js" \ + "libp2p-websockets/node_modules/mafmt/src/index.js" \ + "libp2p-websockets/node_modules/multiaddr/src/codec.js" \ + "libp2p-websockets/node_modules/multiaddr/src/index.js" \ + "libp2p-websockets/src/index.js" \ + "libp2p-websockets/src/listener.js" \ + "libp2p-websockets/src/ma-to-url.js" \ + "libp2p/src/index.js" \ + "mafmt/src/index.js" \ + "multiaddr/src/codec.js" \ + "multiaddr/src/index.js" \ + "multibase/src/base.js" \ + "multibase/src/base16.js" \ + "multibase/src/constants.js" \ + "multibase/src/index.js" \ + "multicodec/src/index.js" \ + "multicodec/src/name-table.js" \ + "multicodec/src/util.js" \ + "multicodec/src/varint-table.js" \ + "multihashes/src/index.js" \ + "multihashing-async/src/blake.js" \ + "multihashing-async/src/crypto-sha1-2-browser.js" \ + "multihashing-async/src/index.js" \ + "multihashing-async/src/utils.js" \ + "multiplex/src/channel.js" \ + "multiplex/src/index.js" \ + "multistream-select/src/dialer/index.js" \ + "multistream-select/src/listener/index.js" \ + "multistream-select/src/listener/ls-handler.js" \ + "multistream-select/src/listener/select-handler.js" \ + "multistream-select/src/select.js" \ + "multistream-select/src/util.js" \ + "peer-book/src/index.js" \ + "peer-id/src/index.js" \ + "peer-info/src/index.js" \ + "peer-info/src/multiaddr-set.js" \ + "pull-length-prefixed/src/decode.js" \ + "pull-length-prefixed/src/encode.js" \ + "smart-buffer/build/smartbuffer.js" \ + "sparse-array/index.js" \ + "time-cache/src/index.js" \ + "varint-decoder/src/index.js" \ + "y-array/src/Array.js" \ + "y-indexeddb/src/IndexedDB.js" \ + "y-ipfs-connector/src/decode.js" \ + "y-ipfs-connector/src/encode.js" \ + "y-ipfs-connector/src/index.js" \ + "y-memory/src/Memory.js" \ + "y-memory/src/RedBlackTree.js" \ + "yjs/src/Connector.js" \ + "yjs/src/Connectors/Test.js" \ + "yjs/src/Database.js" \ + "yjs/src/Struct.js" \ + "yjs/src/Transaction.js" \ + "yjs/src/Utils.js" \ + "yjs/src/y.js" \ + "cids/src/index.js"; do + hack_source $file +done + +echo "Done." diff --git a/packages/thicket-webapp/scripts/hack-source.sh b/packages/thicket-webapp/scripts/hack-source.sh new file mode 100755 index 0000000..868fd33 --- /dev/null +++ b/packages/thicket-webapp/scripts/hack-source.sh @@ -0,0 +1,7 @@ +hack_source() { + file="./node_modules/$1" + echo "babelify $file" + ./node_modules/babel-cli/bin/babel.js $file --presets=es2015 -o $file + echo "uglify $file" + ./node_modules/uglify-es/bin/uglifyjs $file -o $file +} diff --git a/packages/thicket-webapp/yarn.lock b/packages/thicket-webapp/yarn.lock index 905fffe..640ea8a 100644 --- a/packages/thicket-webapp/yarn.lock +++ b/packages/thicket-webapp/yarn.lock @@ -434,6 +434,27 @@ b64@3.x.x: version "3.0.3" resolved "https://registry.yarnpkg.com/b64/-/b64-3.0.3.tgz#36afeee0d9345f046387ce6de8a6702afe5bb56e" +babel-cli@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" + dependencies: + babel-core "^6.26.0" + babel-polyfill "^6.26.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + commander "^2.11.0" + convert-source-map "^1.5.0" + fs-readdir-recursive "^1.0.0" + glob "^7.1.2" + lodash "^4.17.4" + output-file-sync "^1.1.2" + path-is-absolute "^1.0.1" + slash "^1.0.0" + source-map "^0.5.6" + v8flags "^2.1.1" + optionalDependencies: + chokidar "^1.6.1" + babel-code-frame@6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" @@ -975,6 +996,14 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" +babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" + dependencies: + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" + babel-preset-env@1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.5.2.tgz#cd4ae90a6e94b709f97374b33e5f8b983556adef" @@ -1635,7 +1664,7 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" -chokidar@^1.6.0, chokidar@^1.7.0: +chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -3408,6 +3437,10 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -3630,7 +3663,7 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -6569,6 +6602,14 @@ osenv@^0.1.0, osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +output-file-sync@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -7804,6 +7845,10 @@ regenerate@^1.2.1: version "1.3.3" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" +regenerator-runtime@^0.10.5: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + regenerator-runtime@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1" @@ -9074,6 +9119,13 @@ ua-parser-js@^0.7.9: version "0.7.14" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca" +uglify-es@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.1.3.tgz#a21eeb149cb120a1f8302563689e19496550780b" + dependencies: + commander "~2.11.0" + source-map "~0.5.1" + uglify-js@3.1.x, uglify-js@^3.0.13: version "3.1.2" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.2.tgz#b50bcf15a5fd9e9ed40afbcdef3b59d6891b291f" @@ -9230,6 +9282,10 @@ url@^0.11.0: punycode "1.3.2" querystring "0.2.0" +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -9275,6 +9331,12 @@ uws@~0.14.4: version "0.14.5" resolved "https://registry.yarnpkg.com/uws/-/uws-0.14.5.tgz#67aaf33c46b2a587a5f6666d00f7691328f149dc" +v8flags@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + dependencies: + user-home "^1.1.1" + validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" From 4299977fa9bbfe5481a38adf024ac93df07c6efa Mon Sep 17 00:00:00 2001 From: Gorka Date: Mon, 16 Oct 2017 12:07:36 +0200 Subject: [PATCH 2/6] Remove local scripts and dependencies --- packages/thicket-webapp/package.json | 4 +- packages/thicket-webapp/scripts/deploy.sh | 3 - packages/thicket-webapp/scripts/hack-build.sh | 232 ------------------ .../thicket-webapp/scripts/hack-source.sh | 7 - packages/thicket-webapp/yarn.lock | 66 +---- 5 files changed, 3 insertions(+), 309 deletions(-) delete mode 100755 packages/thicket-webapp/scripts/deploy.sh delete mode 100755 packages/thicket-webapp/scripts/hack-build.sh delete mode 100755 packages/thicket-webapp/scripts/hack-source.sh diff --git a/packages/thicket-webapp/package.json b/packages/thicket-webapp/package.json index 32db31d..8f8005c 100644 --- a/packages/thicket-webapp/package.json +++ b/packages/thicket-webapp/package.json @@ -43,8 +43,6 @@ "npm": "5.4.2" }, "devDependencies": { - "babel-cli": "^6.26.0", - "surge": "^0.19.0", - "uglify-es": "^3.1.3" + "surge": "^0.19.0" } } diff --git a/packages/thicket-webapp/scripts/deploy.sh b/packages/thicket-webapp/scripts/deploy.sh deleted file mode 100755 index 1825053..0000000 --- a/packages/thicket-webapp/scripts/deploy.sh +++ /dev/null @@ -1,3 +0,0 @@ -yarn build -mv ./build/index.html ./build/200.html -node_modules/.bin/surge ./build https://thicket.surge.sh diff --git a/packages/thicket-webapp/scripts/hack-build.sh b/packages/thicket-webapp/scripts/hack-build.sh deleted file mode 100755 index 202c3f6..0000000 --- a/packages/thicket-webapp/scripts/hack-build.sh +++ /dev/null @@ -1,232 +0,0 @@ -. ./scripts/hack-source.sh - -for file in \ - "borc/src/decoder.js" \ - "borc/src/diagnose.js" \ - "borc/src/encoder.js" \ - "borc/src/simple.js" \ - "borc/src/tagged.js" \ - "borc/src/utils.js" \ - "datastore-core/src/keytransform.js" \ - "datastore-core/src/mount.js" \ - "datastore-core/src/namespace.js" \ - "datastore-core/src/shard-readme.js" \ - "datastore-core/src/shard.js" \ - "datastore-core/src/sharding.js" \ - "datastore-core/src/tiered.js" \ - "datastore-level/src/index.js" \ - "hyperdiff/lib/index.js" \ - "interface-connection/src/connection.js" \ - "interface-datastore/src/key.js" \ - "interface-datastore/src/memory.js" \ - "interface-datastore/src/utils.js" \ - "ipfs-bitswap/src/decision-engine/index.js" \ - "ipfs-bitswap/src/decision-engine/ledger.js" \ - "ipfs-bitswap/src/index.js" \ - "ipfs-bitswap/src/network.js" \ - "ipfs-bitswap/src/notifications.js" \ - "ipfs-bitswap/src/types/message/entry.js" \ - "ipfs-bitswap/src/types/message/index.js" \ - "ipfs-bitswap/src/types/message/message.proto.js" \ - "ipfs-bitswap/src/types/wantlist/entry.js" \ - "ipfs-bitswap/src/types/wantlist/index.js" \ - "ipfs-bitswap/src/utils.js" \ - "ipfs-bitswap/src/want-manager/index.js" \ - "ipfs-bitswap/src/want-manager/msg-queue.js" \ - "ipfs-block-service/src/index.js" \ - "ipfs-block/node_modules/cids/src/index.js" \ - "ipfs-block/src/index.js" \ - "ipfs-pubsub-room/src/connection.js" \ - "ipfs-pubsub-room/src/encoding.js" \ - "ipfs-pubsub-room/src/index.js" \ - "ipfs-repo/src/api-addr.js" \ - "ipfs-repo/src/blockstore.js" \ - "ipfs-repo/src/config.js" \ - "ipfs-repo/src/index.js" \ - "ipfs-repo/src/lock-memory.js" \ - "ipfs-repo/src/version.js" \ - "ipfs-unixfs-engine/src/builder/balanced/balanced-reducer.js" \ - "ipfs-unixfs-engine/src/builder/builder.js" \ - "ipfs-unixfs-engine/src/builder/create-build-stream.js" \ - "ipfs-unixfs-engine/src/builder/flat/index.js" \ - "ipfs-unixfs-engine/src/builder/reduce.js" \ - "ipfs-unixfs-engine/src/builder/trickle/trickle-reducer.js" \ - "ipfs-unixfs-engine/src/chunker/fixed-size.js" \ - "ipfs-unixfs-engine/src/hamt/bucket.js" \ - "ipfs-unixfs-engine/src/exporter/clean-multihash.js" \ - "ipfs-unixfs-engine/src/exporter/dir-flat.js" \ - "ipfs-unixfs-engine/src/exporter/dir-hamt-sharded.js" \ - "ipfs-unixfs-engine/src/exporter/file.js" \ - "ipfs-unixfs-engine/src/exporter/index.js" \ - "ipfs-unixfs-engine/src/exporter/object.js" \ - "ipfs-unixfs-engine/src/hamt/bucket.js" \ - "ipfs-unixfs-engine/src/hamt/consumable-buffer.js" \ - "ipfs-unixfs-engine/src/hamt/consumable-hash.js" \ - "ipfs-unixfs-engine/src/importer/dir-flat.js" \ - "ipfs-unixfs-engine/src/importer/dir-sharded.js" \ - "ipfs-unixfs-engine/src/importer/dir.js" \ - "ipfs-unixfs-engine/src/importer/flat-to-shard.js" \ - "ipfs-unixfs-engine/src/importer/index.js" \ - "ipfs-unixfs-engine/src/importer/tree-builder.js" \ - "ipfs-unixfs/src/index.js" \ - "ipfs-unixfs/src/unixfs.proto.js" \ - "ipfs/src/core/boot.js" \ - "ipfs/src/core/components/bitswap.js" \ - "ipfs/src/core/components/block.js" \ - "ipfs/src/core/components/bootstrap.js" \ - "ipfs/src/core/components/config.js" \ - "ipfs/src/core/components/dag.js" \ - "ipfs/src/core/components/dht.js" \ - "ipfs/src/core/components/files.js" \ - "ipfs/src/core/components/id.js" \ - "ipfs/src/core/components/init.js" \ - "ipfs/src/core/components/is-online.js" \ - "ipfs/src/core/components/libp2p.js" \ - "ipfs/src/core/components/object.js" \ - "ipfs/src/core/components/ping.js" \ - "ipfs/src/core/components/pre-start.js" \ - "ipfs/src/core/components/pubsub.js" \ - "ipfs/src/core/components/repo.js" \ - "ipfs/src/core/components/start.js" \ - "ipfs/src/core/components/stop.js" \ - "ipfs/src/core/components/swarm.js" \ - "ipfs/src/core/components/version.js" \ - "ipfs/src/core/index.js" \ - "ipfs/src/core/runtime/libp2p-browser.js" \ - "ipfs/src/core/runtime/repo-browser.js" \ - "ipfs/src/core/state.js" \ - "ipld-dag-cbor/src/resolver.js" \ - "ipld-dag-cbor/src/util.js" \ - "ipld-dag-pb/src/dag-link/index.js" \ - "ipld-dag-pb/src/dag-link/index.js" \ - "ipld-dag-pb/src/dag-node/create.js" \ - "ipld-dag-pb/src/dag-node/index.js" \ - "ipld-dag-pb/src/dag-node/rmLink.js" \ - "ipld-dag-pb/src/dag-node/util.js" \ - "ipld-dag-pb/src/dag.proto.js" \ - "ipld-dag-pb/src/resolver.js" \ - "ipld-dag-pb/src/util.js" \ - "ipld-eth-star/eth-block-list/index.js" \ - "ipld-eth-star/util/createIsLink.js" \ - "ipld-eth-star/util/createResolver.js" \ - "ipld-eth-star/util/createTrieResolver.js" \ - "ipld-eth-star/util/createUtil.js" \ - "ipld-eth-star/util/toIpfsBlock.js" \ - "ipld-git/src/resolver.js" \ - "ipld-git/src/util.js" \ - "ipld-git/src/util/commit.js" \ - "ipld-git/src/util/tag.js" \ - "ipld-git/src/util/tree.js" \ - "ipld-git/src/util/util.js" \ - "ipld-resolver/src/index.js" \ - "libp2p-crypto-secp256k1/src/crypto.js" \ - "libp2p-crypto-secp256k1/src/index.js" \ - "libp2p-crypto/src/aes/index.js" \ - "libp2p-crypto/src/hmac/index-browser.js" \ - "libp2p-crypto/src/keys/ecdh-browser.js" \ - "libp2p-crypto/src/keys/ed25519-class.js" \ - "libp2p-crypto/src/keys/ed25519.js" \ - "libp2p-crypto/src/keys/ephemeral-keys.js" \ - "libp2p-crypto/src/keys/index.js" \ - "libp2p-crypto/src/keys/key-stretcher.js" \ - "libp2p-crypto/src/keys/keys.proto.js" \ - "libp2p-crypto/src/keys/rsa-browser.js" \ - "libp2p-crypto/src/keys/rsa-class.js" \ - "libp2p-crypto/src/nodeify.js" \ - "libp2p-crypto/src/util.js" \ - "libp2p-crypto/src/webcrypto.js" \ - "libp2p-floodsub/src/index.js" \ - "libp2p-floodsub/src/message/rpc.proto.js" \ - "libp2p-floodsub/src/message/topic-descriptor.proto.js" \ - "libp2p-floodsub/src/peer.js" \ - "libp2p-floodsub/src/utils.js" \ - "libp2p-identify/src/dialer.js" \ - "libp2p-identify/src/listener.js" \ - "libp2p-identify/src/message.js" \ - "libp2p-multiplex/src/index.js" \ - "libp2p-multiplex/src/muxer.js" \ - "libp2p-ping/src/handler.js" \ - "libp2p-ping/src/ping.js" \ - "libp2p-ping/src/util.js" \ - "libp2p-railing/src/index.js" \ - "libp2p-secio/src/etm.js" \ - "libp2p-secio/src/handshake/crypto.js" \ - "libp2p-secio/src/handshake/exchange.js" \ - "libp2p-secio/src/handshake/finish.js" \ - "libp2p-secio/src/handshake/index.js" \ - "libp2p-secio/src/handshake/propose.js" \ - "libp2p-secio/src/handshake/secio.proto.js" \ - "libp2p-secio/src/index.js" \ - "libp2p-secio/src/state.js" \ - "libp2p-secio/src/support.js" \ - "libp2p-swarm/src/connection.js" \ - "libp2p-swarm/src/dial.js" \ - "libp2p-swarm/src/get-peer-info.js" \ - "libp2p-swarm/src/index.js" \ - "libp2p-swarm/src/limit-dialer/index.js" \ - "libp2p-swarm/src/limit-dialer/queue.js" \ - "libp2p-swarm/src/plaintext.js" \ - "libp2p-swarm/src/protocol-muxer.js" \ - "libp2p-swarm/src/transport.js" \ - "libp2p-webrtc-star/src/index.js" \ - "libp2p-webrtc-star/src/utils.js" \ - "libp2p-websockets/node_modules/mafmt/src/index.js" \ - "libp2p-websockets/node_modules/multiaddr/src/codec.js" \ - "libp2p-websockets/node_modules/multiaddr/src/index.js" \ - "libp2p-websockets/src/index.js" \ - "libp2p-websockets/src/listener.js" \ - "libp2p-websockets/src/ma-to-url.js" \ - "libp2p/src/index.js" \ - "mafmt/src/index.js" \ - "multiaddr/src/codec.js" \ - "multiaddr/src/index.js" \ - "multibase/src/base.js" \ - "multibase/src/base16.js" \ - "multibase/src/constants.js" \ - "multibase/src/index.js" \ - "multicodec/src/index.js" \ - "multicodec/src/name-table.js" \ - "multicodec/src/util.js" \ - "multicodec/src/varint-table.js" \ - "multihashes/src/index.js" \ - "multihashing-async/src/blake.js" \ - "multihashing-async/src/crypto-sha1-2-browser.js" \ - "multihashing-async/src/index.js" \ - "multihashing-async/src/utils.js" \ - "multiplex/src/channel.js" \ - "multiplex/src/index.js" \ - "multistream-select/src/dialer/index.js" \ - "multistream-select/src/listener/index.js" \ - "multistream-select/src/listener/ls-handler.js" \ - "multistream-select/src/listener/select-handler.js" \ - "multistream-select/src/select.js" \ - "multistream-select/src/util.js" \ - "peer-book/src/index.js" \ - "peer-id/src/index.js" \ - "peer-info/src/index.js" \ - "peer-info/src/multiaddr-set.js" \ - "pull-length-prefixed/src/decode.js" \ - "pull-length-prefixed/src/encode.js" \ - "smart-buffer/build/smartbuffer.js" \ - "sparse-array/index.js" \ - "time-cache/src/index.js" \ - "varint-decoder/src/index.js" \ - "y-array/src/Array.js" \ - "y-indexeddb/src/IndexedDB.js" \ - "y-ipfs-connector/src/decode.js" \ - "y-ipfs-connector/src/encode.js" \ - "y-ipfs-connector/src/index.js" \ - "y-memory/src/Memory.js" \ - "y-memory/src/RedBlackTree.js" \ - "yjs/src/Connector.js" \ - "yjs/src/Connectors/Test.js" \ - "yjs/src/Database.js" \ - "yjs/src/Struct.js" \ - "yjs/src/Transaction.js" \ - "yjs/src/Utils.js" \ - "yjs/src/y.js" \ - "cids/src/index.js"; do - hack_source $file -done - -echo "Done." diff --git a/packages/thicket-webapp/scripts/hack-source.sh b/packages/thicket-webapp/scripts/hack-source.sh deleted file mode 100755 index 868fd33..0000000 --- a/packages/thicket-webapp/scripts/hack-source.sh +++ /dev/null @@ -1,7 +0,0 @@ -hack_source() { - file="./node_modules/$1" - echo "babelify $file" - ./node_modules/babel-cli/bin/babel.js $file --presets=es2015 -o $file - echo "uglify $file" - ./node_modules/uglify-es/bin/uglifyjs $file -o $file -} diff --git a/packages/thicket-webapp/yarn.lock b/packages/thicket-webapp/yarn.lock index 640ea8a..905fffe 100644 --- a/packages/thicket-webapp/yarn.lock +++ b/packages/thicket-webapp/yarn.lock @@ -434,27 +434,6 @@ b64@3.x.x: version "3.0.3" resolved "https://registry.yarnpkg.com/b64/-/b64-3.0.3.tgz#36afeee0d9345f046387ce6de8a6702afe5bb56e" -babel-cli@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" - dependencies: - babel-core "^6.26.0" - babel-polyfill "^6.26.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - commander "^2.11.0" - convert-source-map "^1.5.0" - fs-readdir-recursive "^1.0.0" - glob "^7.1.2" - lodash "^4.17.4" - output-file-sync "^1.1.2" - path-is-absolute "^1.0.1" - slash "^1.0.0" - source-map "^0.5.6" - v8flags "^2.1.1" - optionalDependencies: - chokidar "^1.6.1" - babel-code-frame@6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" @@ -996,14 +975,6 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-polyfill@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" - dependencies: - babel-runtime "^6.26.0" - core-js "^2.5.0" - regenerator-runtime "^0.10.5" - babel-preset-env@1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.5.2.tgz#cd4ae90a6e94b709f97374b33e5f8b983556adef" @@ -1664,7 +1635,7 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" -chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0: +chokidar@^1.6.0, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -3437,10 +3408,6 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" -fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -3663,7 +3630,7 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -6602,14 +6569,6 @@ osenv@^0.1.0, osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" - dependencies: - graceful-fs "^4.1.4" - mkdirp "^0.5.1" - object-assign "^4.1.0" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -7845,10 +7804,6 @@ regenerate@^1.2.1: version "1.3.3" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" -regenerator-runtime@^0.10.5: - version "0.10.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" - regenerator-runtime@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1" @@ -9119,13 +9074,6 @@ ua-parser-js@^0.7.9: version "0.7.14" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca" -uglify-es@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.1.3.tgz#a21eeb149cb120a1f8302563689e19496550780b" - dependencies: - commander "~2.11.0" - source-map "~0.5.1" - uglify-js@3.1.x, uglify-js@^3.0.13: version "3.1.2" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.2.tgz#b50bcf15a5fd9e9ed40afbcdef3b59d6891b291f" @@ -9282,10 +9230,6 @@ url@^0.11.0: punycode "1.3.2" querystring "0.2.0" -user-home@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -9331,12 +9275,6 @@ uws@~0.14.4: version "0.14.5" resolved "https://registry.yarnpkg.com/uws/-/uws-0.14.5.tgz#67aaf33c46b2a587a5f6666d00f7691328f149dc" -v8flags@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" - dependencies: - user-home "^1.1.1" - validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" From dcb9e86420c3d4730b088d51ae065409b69dc1cf Mon Sep 17 00:00:00 2001 From: Gorka Date: Mon, 16 Oct 2017 12:08:45 +0200 Subject: [PATCH 3/6] Eject create-react-app --- packages/thicket-webapp/config/env.js | 90 +++++ .../config/jest/cssTransform.js | 14 + .../config/jest/fileTransform.js | 12 + packages/thicket-webapp/config/paths.js | 55 +++ packages/thicket-webapp/config/polyfills.js | 16 + .../config/webpack.config.dev.js | 264 ++++++++++++++ .../config/webpack.config.prod.js | 334 ++++++++++++++++++ .../config/webpackDevServer.config.js | 92 +++++ packages/thicket-webapp/package.json | 86 ++++- packages/thicket-webapp/scripts/build.js | 150 ++++++++ packages/thicket-webapp/scripts/start.js | 92 +++++ packages/thicket-webapp/scripts/test.js | 27 ++ 12 files changed, 1226 insertions(+), 6 deletions(-) create mode 100644 packages/thicket-webapp/config/env.js create mode 100644 packages/thicket-webapp/config/jest/cssTransform.js create mode 100644 packages/thicket-webapp/config/jest/fileTransform.js create mode 100644 packages/thicket-webapp/config/paths.js create mode 100644 packages/thicket-webapp/config/polyfills.js create mode 100644 packages/thicket-webapp/config/webpack.config.dev.js create mode 100644 packages/thicket-webapp/config/webpack.config.prod.js create mode 100644 packages/thicket-webapp/config/webpackDevServer.config.js create mode 100644 packages/thicket-webapp/scripts/build.js create mode 100644 packages/thicket-webapp/scripts/start.js create mode 100644 packages/thicket-webapp/scripts/test.js diff --git a/packages/thicket-webapp/config/env.js b/packages/thicket-webapp/config/env.js new file mode 100644 index 0000000..8b39b6c --- /dev/null +++ b/packages/thicket-webapp/config/env.js @@ -0,0 +1,90 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +var dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + `${paths.dotenv}.${NODE_ENV}`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. +// https://github.com/motdotla/dotenv +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv').config({ + path: dotenvFile, + }); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebookincubator/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. +// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in Webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + } + ); + // Stringify all values so we can feed into Webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/packages/thicket-webapp/config/jest/cssTransform.js b/packages/thicket-webapp/config/jest/cssTransform.js new file mode 100644 index 0000000..f1534f6 --- /dev/null +++ b/packages/thicket-webapp/config/jest/cssTransform.js @@ -0,0 +1,14 @@ +'use strict'; + +// This is a custom Jest transformer turning style imports into empty objects. +// http://facebook.github.io/jest/docs/tutorial-webpack.html + +module.exports = { + process() { + return 'module.exports = {};'; + }, + getCacheKey() { + // The output is always the same. + return 'cssTransform'; + }, +}; diff --git a/packages/thicket-webapp/config/jest/fileTransform.js b/packages/thicket-webapp/config/jest/fileTransform.js new file mode 100644 index 0000000..ffce0da --- /dev/null +++ b/packages/thicket-webapp/config/jest/fileTransform.js @@ -0,0 +1,12 @@ +'use strict'; + +const path = require('path'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/tutorial-webpack.html + +module.exports = { + process(src, filename) { + return `module.exports = ${JSON.stringify(path.basename(filename))};`; + }, +}; diff --git a/packages/thicket-webapp/config/paths.js b/packages/thicket-webapp/config/paths.js new file mode 100644 index 0000000..6d16efc --- /dev/null +++ b/packages/thicket-webapp/config/paths.js @@ -0,0 +1,55 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const url = require('url'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebookincubator/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +const envPublicUrl = process.env.PUBLIC_URL; + +function ensureSlash(path, needsSlash) { + const hasSlash = path.endsWith('/'); + if (hasSlash && !needsSlash) { + return path.substr(path, path.length - 1); + } else if (!hasSlash && needsSlash) { + return `${path}/`; + } else { + return path; + } +} + +const getPublicUrl = appPackageJson => + envPublicUrl || require(appPackageJson).homepage; + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// Webpack needs to know it to put the right