├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── assets
├── audius.png
├── audius_big.png
├── audius_inverted.png
├── icon.icns
├── icon.ico
└── icons
│ ├── 128x128.png
│ ├── 16x16.png
│ ├── 24x24.png
│ ├── 256x256.png
│ ├── 32x32.png
│ ├── 48x48.png
│ ├── 512x512.png
│ ├── 64x64.png
│ └── 96x96.png
├── config
├── env.js
├── jest
│ ├── cssTransform.js
│ └── fileTransform.js
├── paths.js
├── webpack.config.dev.js
├── webpack.config.prod.js
└── webpackDevServer.config.js
├── docs
├── README.md
├── build-instructions
│ ├── linux.md
│ ├── mac.md
│ └── windows.md
└── plans.md
├── package.json
├── scripts
├── bootstrap.js
├── build.js
├── start.js
└── test.js
├── src
├── actions
│ ├── downloadQueue.js
│ └── searchQuery.js
├── app.global.css
├── app.html
├── app.main.js
├── app.renderer.js
├── components
│ ├── About
│ │ ├── electron-logo.svg
│ │ └── index.jsx
│ ├── Dialog.jsx
│ ├── DownloadQueue.jsx
│ ├── Home
│ │ ├── audius_big.png
│ │ └── index.jsx
│ ├── Notification.jsx
│ ├── Query
│ │ ├── AudioInfo.jsx
│ │ ├── DownloadAudio.jsx
│ │ ├── PlayAudio.jsx
│ │ ├── default-artwork.png
│ │ └── index.jsx
│ ├── Settings
│ │ └── index.jsx
│ ├── Terms
│ │ └── index.jsx
│ ├── TopAppBar.jsx
│ ├── TopMenuList.jsx
│ └── WindowHandlers.jsx
├── modules
│ ├── AutoUpdater.js
│ ├── Settings.js
│ ├── SpotifyWebApi.js
│ ├── YTDownload.js
│ ├── YTSearch.js
│ ├── ffmpeg-wrapper.js
│ ├── log.js
│ ├── queryCheck.js
│ └── rainbowWrapper.js
├── reducers
│ ├── downloadQueue.js
│ ├── index.js
│ └── searchQuery.js
├── store
│ └── configureStore.js
└── theme
│ └── AudiusTheme.jsx
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /react-compiled
11 | /dist
12 | /bin
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Configuration file Travis CI
2 | # Author - Mihir Pathak
3 | #
4 | # Consists of 2 jobs -
5 | # - Linux environment builds for debian
6 | # - OSX builds for Mac and Windows
7 |
8 | # Build with Node JS 8 [9+ causes fsevetns build to crash in darwin]
9 | language: node_js
10 | node_js: "8"
11 |
12 | # Job for building
13 | jobs:
14 | include:
15 | - if: tag IS present
16 | os: linux
17 | dist: trusty
18 | - if: tag IS present
19 | os: osx
20 | osx_image: xcode9.3
21 |
22 | # Global environment variables
23 | env:
24 | global:
25 | - ELECTRON_CACHE=$HOME/.cache/electron
26 | - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
27 |
28 | # Cache directorries
29 | cache:
30 | directories:
31 | - node_modules
32 | - $HOME/.cache/electron
33 | - $HOME/.cache/electron-builder
34 |
35 | # Perform build [win32's exe and darwin's dmg in osx and linux's deb in linux]
36 | script:
37 | - echo "Initializing app files..."
38 | - yarn init-app
39 | - echo "Compiling React app for production"
40 | - yarn build
41 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
42 | echo "Packaging Audius for Linux x64 (.deb)";
43 | chmod a+x bin/ffmpeg/linux/ffmpeg;
44 | chmod a+x bin/rainbow/linux/rainbow;
45 | yarn package-linux;
46 | fi
47 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
48 | echo "Packaging Audius for MacOS X (.dmg)";
49 | chmod a+x bin/ffmpeg/darwin/ffmpeg;
50 | chmod a+x bin/rainbow/darwin/rainbow;
51 | yarn package-mac;
52 | echo "Packaging Audius for Windows x64 (.exe)";
53 | yarn package-win;
54 | fi
55 |
56 | after_success:
57 | - echo "Build completed, uploaded artifacts (if any)"
58 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | ## [1.6.0-beta1] - 2018-01-03
5 | ### Added
6 | - Custom URI protocol `audius://` for serving static files
7 |
8 | ### Changed
9 | - Get latest webpack configs from `create-react-app`
10 | - Moved packages to `devDependencies` to reduce asar bundle size
11 |
12 | ### Fixed
13 | - Font issue
14 | - Webpack production errors
15 | - [Queue] Fix mixing `require` and `exports`
16 |
17 | ## [1.6.0-beta1] - 2018-01-03
18 | ### Added
19 | - Support for Spotify links!
20 | - **Note** Only track links work. Playlists and albums will be supported
21 | in the next point release
22 | - Default art work for songs with unknown Spotify data
23 |
24 | ### Changed
25 | - Minor UI changes
26 | - Add `Open Sans` font locally
27 | - [Hack] Relative path issue for loading local fonts
28 | - [win32] Installer will now install per-user
29 |
30 | ### Fixed
31 | - Refreshing Spotify access token in runtime
32 | - Error dialog while getting Spotify access token
33 |
34 | ## [1.6.0-alpha1] - 2018-09-30
35 | ### Added
36 | - Download Queue!
37 | - Redux!
38 | - Support for YouTube links!
39 | - **Note** Some YT links will not fetch Spotify data properly. Working on a fix
40 |
41 | ### Changed
42 | - Updated node packages
43 | - electron - 2.0.7 -> 3.0.2
44 | - react - 16.4.x -> 16.5.2
45 | - material-ui - 1.x -> 3.1.1
46 | - And more!
47 | - Minor UI changes
48 | - Move to promise based modules
49 | - Use HashRouter for in-app routing
50 | - Fix icons
51 |
52 | ### Removed
53 | - Nuked audio play functionality as it violates YouTube's terms
54 | - Now opens the link in default browser
55 | - Nuked `@material-ui/icons`. Using Font Awesome entirely
56 |
57 | ## [1.5.0] - 2018-08-19
58 | **NOTE -** This is the final release for 1.x.x. I will shortly begin work on 2.x :grin:
59 |
60 | This branch may or may not recieve bug fixes. Feel free to fork the repo and make changes
61 |
62 | ### Changed
63 | - Updated node packages
64 | - electron - 2.0.7 -> 2.0.10
65 |
66 | ## [1.5.0-beta1] - 2018-08-19
67 | ### Added
68 | - Logging! Now it's easier to debug the application
69 | - Log files location is platform dependent
70 |
71 | ### Changed
72 | - Updated node packages
73 | - electron - 2.0.2 -> 2.0.7
74 | - electron-updater - 2.21.10 -> 3.1.1
75 | - And more!
76 |
77 | ## [1.4.2] - 2018-08-18
78 | ### Fixed
79 | - Uncaught error while fetching access token in main process
80 |
81 | ## [1.4.1] - 2018-08-01
82 | ### Fixed
83 | - Refresh Spotify token on-demand
84 |
85 | ## [1.4.0] - 2018-07-01
86 | ### Changed
87 | - Display upto 10 search results
88 |
89 | ### Fixed
90 | - "Go back" re-renders current view
91 |
92 | ## [1.3.0-beta1] - 2018-06-26
93 | ### Changed
94 | - rainbow is no longer experimental!
95 | - Default download format for OSX is m4a
96 | - rainbow is enabled by default
97 |
98 | ## [1.3.0-beta1] - 2018-06-26
99 | ### Added
100 | - [Experimental] Rainbow can now embed tags in M4A files too!
101 |
102 | ### Changed
103 | - rainbow now uses positional arguments
104 |
105 | ## [1.3.0-alpha2] - 2018-06-24
106 | ### Added
107 | - [Experimental] Added rainbow for all platforms
108 | - Added toggle switch in Settigns to embed metadata
109 |
110 | ### Changed
111 | - Changed the way the app compiles external binaries
112 |
113 | ### Removed
114 | - All built in binaries inside the repository
115 |
116 | ## [1.3.0-alpha1] - 2018-06-23
117 | ### Added
118 | - [Experimental] Added rainbow for embedding ID3 in win32
119 |
120 | ### Changed
121 | - Lint ES6 code
122 |
123 | ## [1.2.1] - 2018-06-22
124 | ### Changed
125 | - Remove unused dependencies [lesser app size]
126 | - NSIS installer will not ask for elevated permissions
127 |
128 | ## [1.2.0] - 2018-06-22
129 | ### Changed
130 | - include files for electron-builder
131 |
132 | ## [1.2.0-beta1] - 2018-06-22
133 | ### Changed
134 | - New Layout!
135 | - Cleaner, Leaner code
136 | - Re-organize entire app structure for efficiency
137 |
138 | ### Fixed
139 | - FFmpeg path issues in production
140 |
141 | ## [1.1.0] - 2018-06-20
142 | ### Added
143 | - Auto Update is now fully functional
144 |
145 | ## [1.0.2] - 2018-06-19
146 | ### Changed
147 | - Use proper JSX syntax
148 | - Query - remove useless code
149 | - Modified build scripts
150 |
151 | ## [1.0.1] - 2018-06-15
152 | ### Added
153 | - electron-log for logging
154 |
155 | ### Changed
156 | - Cleanup unnecessary build code
157 | - Temporarily drop auto-updater support
158 | - Clean up Terms and About
159 |
160 | ## [1.0.0] - 2018-06-08
161 | ### Added
162 | - FFmpeg binary for all platforms
163 | - Added ability to modify settings
164 |
165 | ### Changed
166 | - Debian package specific config
167 | - Settings - use table layout
168 | - Default download location is `$HOME/Misic`
169 | - electron-builder publish config
170 |
171 | ### Fixed
172 | - Fix FFMPEG_PATH related issues for all platforms
173 | - Fix Query onSubmit
174 | - Fix FFmpeg binary permission issues in OsX and Linux
175 |
176 | ## [1.0.0-beta3] - 2018-06-06
177 | ### Added
178 | - Add custom dialog box to display messages and errors
179 | - Customize build script
180 | - **Drop 32-bit support entirely**
181 |
182 | ### Changed
183 | - New dialog box layout
184 | - Make DialogBox as a separate React component
185 | - YouTube and Spotify links are disabled
186 | - Removed useless console log calls
187 |
188 | ### Fixed
189 | - TrackContainer - dialog opens on render()
190 | - YTDownload - return on error
191 | - QueryField - fixed invalid view error
192 | - QueryField - disable toggleError on change
193 | - QueryField - set dialog open to false
194 | - TrackContainer, Query - dialog will not open after first trigger
195 |
196 | ## [1.0.0-beta2] - 2018-06-05
197 | ### Added
198 | - Custom script to build in CI
199 |
200 | ### Changed
201 | - Travis - use a more complex build config
202 |
203 | ### Fixed
204 | - FFMPEG_PATH in non-windows platforms
205 | - **NOTE** - Linux and OSX users need to manually install FFmpeg and set to PATH
206 |
207 | ## [1.0.0-beta1] - 2018-06-05
208 | ### Changed
209 | - Remove unused packages [reduces build size]
210 |
211 | ### Fixed
212 | - Build failure because of condition require in fluent-ffmpeg
213 |
214 | ## [1.0.0-alpha3] - 2018-06-05
215 | ### Added
216 | - Custom README
217 | - Travis CI configuration [Supports multi-platform build!]
218 | - Added image assets
219 |
220 | ### Changed
221 | - Final build files will not have ${platform}
222 |
223 | ### Fixed
224 | - Menu stays open when miniWindow is triggered
225 |
226 | ## [1.0.0-alpha2] - 2018-06-04
227 | ### Added
228 | - Module YTDownload for downloading in MP3
229 | - YTDownload - add progress listener
230 | - YTDownload - multi-format download (mp3 and m4a)
231 | - Settings - basic settings functionalities
232 |
233 | ### Changed
234 | - TrackContainer - implement YTDownload
235 | - TrackContainer - migrate to React.Component
236 | - YTDownload - use filter options to grab 'auidioonly'
237 | - YTDownload - change from downloadMp3 to download() for multi-format support
238 | - TrackContainer - use CircularProgress and disable button while downloading
239 | - webpack - set target to 'node' to enbale nodejs functionalities that do not work in browser mode
240 | - YTDownload - request output format from persistent conf
241 | - YTDownload - get Spotify metadata from props
242 |
243 | ### Fixed
244 | - YTDownload - fix improper module export
245 | - TrackContainer - fix CircularProgress on error
246 | - Fix class names in About and Terms
247 |
248 | ## [1.0.0-alpha1] - 2018-06-03
249 | ### Added
250 | - Terms - add terms of use
251 | - About - add basic content
252 |
253 | ## [1.0.0-pre-alpha] - 2018-06-02
254 | ### Added
255 | - Module YTCore - streaming audio from YouTube
256 | - Module YTSearch - uses YouTube's V3 API to search for songs
257 | - Module SpotifyWebApi - uses Spotify's Web API for requesting metadata
258 | - FFmpeg 4.0 binary for win32 systems [macOS and linux users must install it as a dependency]
259 | - Audius icons for all platforms, courtesy of @turnerboy
260 | - Added react-fortawesome for icon support
261 | - electron-builder config for packaging the app
262 | - TopAppBar - add handlers for both menu items and window navigation
263 | - Query - add custom result container (first VideoContainer then TrackContainer)
264 | - App - custom scrollbar
265 | - VideoContainer - add onClick handler to play audio
266 |
267 | ### Changed
268 | - Use seperate build directory (react-compiled) for react's production builds
269 | - TopAppBar - go back to per-view render mode
270 | - TopAppBar - add "go back" in Search
271 | - TopAppBar - move to font-awesome for window handler icons
272 | - TopAppBar - clean up menu items a bit
273 | - Query - Display query
274 | - electron.js - use YTCore instead of youtube-audio-stream
275 | - YTSearch - crunch results before returning
276 | - YTSearch - use YouTube's API options for filtering results
277 | - electron.js - use electron-settings to set Spotify access_token to be persistent
278 | - TrackContainer - pass some track details as props
279 | - electron-builder - move FFmpeg directory to extraResources
280 | - package.json - add important fields (author, productName, description and more) and remove unused packages
281 |
282 | ### Fixed
283 | - QueryField - wrong URL passed while invoking new BrowserWindow
284 | - electron.js - fix URL path
285 | - Query - fix displaying encoded URI as title
286 | - Query - use decodeURI() before passing to search()
287 | - App - set correct FFMPEG_PATH
288 | - webpack - fix production level transpiling issues (UglifyJS cannot properly transpile ES6)
289 | - App - fix module not found error in main
290 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Mihir Pathak
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ****
4 |
5 | Audius is a cross-platform application which can be used to download songs from YouTube and Spotify
6 |
7 | [](https://travis-ci.com/mihirpathak97/audius)
8 | [](https://travis-ci.com/mihirpathak97/audius)
9 |
10 | **Written with [electronjs](https://electronjs.org/)**
11 |
12 | **Image assets courtesy of [@turnerboy](https://github.com/turnerboy)**
13 |
14 | ## Supported Platforms
15 |
16 | Audius is currently supported for the following platforms:
17 | - Windows 7+ (64-bit)
18 | - Mac OS X 10.9+ (64-bit)
19 | - Ubuntu 12.04+/Debian 8+ (64-bit)
20 |
21 | But, this app can be built for any other platform that is officially supported
22 | by [electronjs](https://github.com/electron/electron/blob/v2.0.2/docs/tutorial/support.md#supported-platforms). Head over to the docs for build instructions
23 |
24 | ## Installing
25 |
26 | Download the latest Audius release [here](https://github.com/mihirpathak97/audius/releases/latest)
27 |
28 | **NOTE**: [OSX] This app is not code-signed so you will have to allow it to be opened in
29 | Privacy and Security settings.
30 |
31 | **NOTE**: Auto updates are not supported in Linux :broken_heart:
32 |
33 | ## Disclaimer
34 |
35 | This app is subject to YouTube's terms and conditions.
36 |
37 | Downloading copyright songs may be illegal in your country. This tool is for educational purposes only and the developer is not responsible in any way for improper use.
38 |
--------------------------------------------------------------------------------
/assets/audius.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/audius.png
--------------------------------------------------------------------------------
/assets/audius_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/audius_big.png
--------------------------------------------------------------------------------
/assets/audius_inverted.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/audius_inverted.png
--------------------------------------------------------------------------------
/assets/icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icon.icns
--------------------------------------------------------------------------------
/assets/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icon.ico
--------------------------------------------------------------------------------
/assets/icons/128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/128x128.png
--------------------------------------------------------------------------------
/assets/icons/16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/16x16.png
--------------------------------------------------------------------------------
/assets/icons/24x24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/24x24.png
--------------------------------------------------------------------------------
/assets/icons/256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/256x256.png
--------------------------------------------------------------------------------
/assets/icons/32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/32x32.png
--------------------------------------------------------------------------------
/assets/icons/48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/48x48.png
--------------------------------------------------------------------------------
/assets/icons/512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/512x512.png
--------------------------------------------------------------------------------
/assets/icons/64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/64x64.png
--------------------------------------------------------------------------------
/assets/icons/96x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mihirpathak97/audius/6f6aa72a5e6f4651c591d2d4a3e7c808793bcd23/assets/icons/96x96.png
--------------------------------------------------------------------------------
/config/env.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const paths = require('./paths');
6 |
7 | // Make sure that including paths.js after env.js will read .env variables.
8 | delete require.cache[require.resolve('./paths')];
9 |
10 | const NODE_ENV = process.env.NODE_ENV;
11 | if (!NODE_ENV) {
12 | throw new Error(
13 | 'The NODE_ENV environment variable is required but was not specified.'
14 | );
15 | }
16 |
17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18 | var dotenvFiles = [
19 | `${paths.dotenv}.${NODE_ENV}.local`,
20 | `${paths.dotenv}.${NODE_ENV}`,
21 | // Don't include `.env.local` for `test` environment
22 | // since normally you expect tests to produce the same
23 | // results for everyone
24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`,
25 | paths.dotenv,
26 | ].filter(Boolean);
27 |
28 | // Load environment variables from .env* files. Suppress warnings using silent
29 | // if this file is missing. dotenv will never modify any environment variables
30 | // that have already been set. Variable expansion is supported in .env files.
31 | // https://github.com/motdotla/dotenv
32 | // https://github.com/motdotla/dotenv-expand
33 | dotenvFiles.forEach(dotenvFile => {
34 | if (fs.existsSync(dotenvFile)) {
35 | require('dotenv-expand')(
36 | require('dotenv').config({
37 | path: dotenvFile,
38 | })
39 | );
40 | }
41 | });
42 |
43 | // We support resolving modules according to `NODE_PATH`.
44 | // This lets you use absolute paths in imports inside large monorepos:
45 | // https://github.com/facebook/create-react-app/issues/253.
46 | // It works similar to `NODE_PATH` in Node itself:
47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
50 | // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51 | // We also resolve them to make sure all tools using them work consistently.
52 | const appDirectory = fs.realpathSync(process.cwd());
53 | process.env.NODE_PATH = (process.env.NODE_PATH || '')
54 | .split(path.delimiter)
55 | .filter(folder => folder && !path.isAbsolute(folder))
56 | .map(folder => path.resolve(appDirectory, folder))
57 | .join(path.delimiter);
58 |
59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60 | // injected into the application via DefinePlugin in Webpack configuration.
61 | const REACT_APP = /^REACT_APP_/i;
62 |
63 | function getClientEnvironment(publicUrl) {
64 | const raw = Object.keys(process.env)
65 | .filter(key => REACT_APP.test(key))
66 | .reduce(
67 | (env, key) => {
68 | env[key] = process.env[key];
69 | return env;
70 | },
71 | {
72 | // Useful for determining whether we’re running in production mode.
73 | // Most importantly, it switches React into the correct mode.
74 | NODE_ENV: process.env.NODE_ENV || 'development',
75 | // Useful for resolving the correct path to static assets in `public`.
76 | // For example,
.
77 | // This should only be used as an escape hatch. Normally you would put
78 | // images into the `src` and `import` them in code to get their paths.
79 | PUBLIC_URL: publicUrl,
80 | }
81 | );
82 | // Stringify all values so we can feed into Webpack DefinePlugin
83 | const stringified = {
84 | 'process.env': Object.keys(raw).reduce((env, key) => {
85 | env[key] = JSON.stringify(raw[key]);
86 | return env;
87 | }, {}),
88 | };
89 |
90 | return { raw, stringified };
91 | }
92 |
93 | module.exports = getClientEnvironment;
94 |
--------------------------------------------------------------------------------
/config/jest/cssTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // This is a custom Jest transformer turning style imports into empty objects.
4 | // http://facebook.github.io/jest/docs/en/webpack.html
5 |
6 | module.exports = {
7 | process() {
8 | return 'module.exports = {};';
9 | },
10 | getCacheKey() {
11 | // The output is always the same.
12 | return 'cssTransform';
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/config/jest/fileTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 |
5 | // This is a custom Jest transformer turning file imports into filenames.
6 | // http://facebook.github.io/jest/docs/en/webpack.html
7 |
8 | module.exports = {
9 | process(src, filename) {
10 | const assetFilename = JSON.stringify(path.basename(filename));
11 |
12 | if (filename.match(/\.svg$/)) {
13 | return `module.exports = {
14 | __esModule: true,
15 | default: ${assetFilename},
16 | ReactComponent: (props) => ({
17 | $$typeof: Symbol.for('react.element'),
18 | type: 'svg',
19 | ref: null,
20 | key: null,
21 | props: Object.assign({}, props, {
22 | children: ${assetFilename}
23 | })
24 | }),
25 | };`;
26 | }
27 |
28 | return `module.exports = ${assetFilename};`;
29 | },
30 | };
31 |
--------------------------------------------------------------------------------
/config/paths.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const url = require('url');
6 |
7 | // Make sure any symlinks in the project folder are resolved:
8 | // https://github.com/facebook/create-react-app/issues/637
9 | const appDirectory = fs.realpathSync(process.cwd());
10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
11 |
12 | const envPublicUrl = process.env.PUBLIC_URL;
13 |
14 | function ensureSlash(inputPath, needsSlash) {
15 | const hasSlash = inputPath.endsWith('/');
16 | if (hasSlash && !needsSlash) {
17 | return inputPath.substr(0, inputPath.length - 1);
18 | } else if (!hasSlash && needsSlash) {
19 | return `${inputPath}/`;
20 | } else {
21 | return inputPath;
22 | }
23 | }
24 |
25 | const getPublicUrl = appPackageJson =>
26 | envPublicUrl || require(appPackageJson).homepage;
27 |
28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
29 | // "public path" at which the app is served.
30 | // Webpack needs to know it to put the right