Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] fix mapbox token issue #757

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
MAPEO_VARIANT: ${{ matrix.variant }}
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
- name: Publish (unsigned)
# Currently undocumented, but if it is None (e.g. PR from a fork) then secrets are not defined
if: github.secret_source != 'Actions'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ storybook-static
updates
temp-resources
.eslintcache
.env
.env*.local
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.14.1
v14.18
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [5.6.3](https://github.com/digidem/mapeo-desktop/compare/v5.6.2...v5.6.3) (2024-05-14)


### Bug Fixes

* update mapbox token ([b484674](https://github.com/digidem/mapeo-desktop/commit/b484674))



### [5.6.2](https://github.com/digidem/mapeo-desktop/compare/v5.6.1...v5.6.2) (2023-08-31)


Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,30 @@ For a mobile application that is compatible with Mapeo Desktop, see [Mapeo Mobil

Read the [online user guide](https://digital-democracy.gitbook.io/mapeo/) for
information on how to install aerial imagery and tiles, custom configurations,
and more.
and more.

![architecture](docs/desktop-architecture.png)

## Getting Started

To clone and install all dependencies and start a process to re-build the app whenever you change a file:
To clone and install all dependencies:

```sh
git clone git@github.com:digidem/mapeo-desktop.git
cd mapeo-desktop
npm install
npm run build:translations
```

Create a `.env` file at the project root that has the following structure (replace `<your_token_here>` with a valid [Mapbox public access token](https://docs.mapbox.com/help/getting-started/access-tokens/)):

```env
MAPBOX_ACCESS_TOKEN=<your_token_here>
```

Start a process to re-build the app whenever you change a file:

```sh
npm run watch
```

Expand All @@ -57,7 +68,6 @@ tail -f USERDATA/Mapeo/logs/$DATE.debug.log

See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for more details.


## Community

Connect with the Mapeo community for support & to contribute!
Expand Down
10 changes: 7 additions & 3 deletions builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ const fs = require('fs')
const path = require('path')
const { nodeFileTrace } = require('@vercel/nft')

require('dotenv').config()

const config = {
afterSign: 'bin/notarize.js',
// afterSign: 'bin/notarize.js',
detectUpdateChannel: true,
generateUpdatesFilesForAllChannels: true,
appId: 'org.digital-democracy.mapeo-desktop',
Expand Down Expand Up @@ -54,7 +56,8 @@ const config = {
{
provider: 's3',
bucket: 'downloads.mapeo.app',
path: process.env.ARCH === 'ia32' ? '/desktop/ia32' : '/desktop'
path: process.env.ARCH === 'ia32' ? '/desktop/ia32' : '/desktop',
publishAutoUpdate: false
},
{
provider: 'github',
Expand All @@ -67,7 +70,8 @@ const config = {
from: path.dirname(require.resolve('mapeo-default-settings')),
to: 'presets/default'
}
]
],
extraMetadata: { mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN }
}

const files = [
Expand Down
23 changes: 20 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
var path = require('path')
var APP_NAME = 'Mapeo'
var APP_TEAM = 'Digital Democracy'
var APP_VERSION = require('./src/build-config').version
var buildConfig = require('./src/build-config')
var APP_VERSION = buildConfig.version
/**
* This is very confusing due to the fact that this file is used across two different contexts, where one is bundled via webpack (renderer)
* and the other is not (main). For context, we need this to work in the following situations:
*
* - The development environment (when you have a .env file)
* - In CI (when you have an env variable exported in the shell),
* - When the app is packaged via electron-builder (renderer code is bundled via webpack, main process code is essentially Node code that gets executed by an Electron executable)
*
* How this is implemented on a technical level:
*
* - In the renderer process, process.env.MAPBOX_ACCESS_TOKEN gets replaced inline by dotenv-webpack.
* - In the main process, process.env.MAPBOX_ACCESS_TOKEN is not defined (unless you export an environment variable when running the app via the CLI).
* In order for the main process to get access to this value, we use electron-builder to read the env variable in the build environment and
* add a field called `mapboxAccessToken` to the packaged package.json file. This is read at runtime by the main process and eventually used in this variable.
*/
var MAPBOX_ACCESS_TOKEN =
process.env.MAPBOX_ACCESS_TOKEN || buildConfig.mapboxAccessToken

var isElectron = typeof process.type === 'string'
// Is `true` when running from Node
Expand All @@ -22,8 +40,7 @@ module.exports = {
// This is super confusing... due to hard-coded paths in @mapeo/settings
// TODO: Clean all of this up in mapeo-server and @mapeo/settings
DEFAULT_CONFIG_DIR: path.join(RESOURCES_DIR, 'presets'),
MAPBOX_ACCESS_TOKEN:
'pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg',
MAPBOX_ACCESS_TOKEN,
GITHUB_URL: 'https://github.com/digidem/mapeo-desktop',
GITHUB_URL_RAW:
'https://raw.githubusercontent.com/digidem/mapeo-desktop/master'
Expand Down
56 changes: 44 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
"name": "mapeo-desktop",
"description": "Mapping and monitoring in remote environments.",
"productName": "Mapeo",
"version": "5.6.2",
"version": "5.6.3",
"productDescription": "Offline Map Editor",
"author": {
"name": "Digital Democracy",
"email": "info@ddem.us"
},
"main": "index.js",
"engine": {
"node": "12.14.1"
},
"scripts": {
"clean": "rimraf \"dist/\"",
"check": "npm-run-all -p check:prod check:prod-unused check:dev",
Expand Down Expand Up @@ -220,6 +217,8 @@
"css-loader": "^3.2.0",
"debug": "^4.1.1",
"dependency-check": "^3.4.1",
"dotenv": "^16.4.5",
"dotenv-webpack": "^8.1.0",
"electron": "^9.4.4",
"electron-builder": "^22.14.10",
"electron-devtools-installer": "^3.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ const pkg = require('../package.json')

module.exports = {
variant: pkg.variant || 'main',
version: pkg.version
version: pkg.version,
mapboxAccessToken: pkg.mapboxAccessToken
}
7 changes: 6 additions & 1 deletion variants/icca/builder.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-disable no-template-curly-in-string */
const path = require('path')

require('dotenv').config({
path: '../../.env'
})

module.exports = async function (config) {
const productName = 'Mapeo for ICCAs'
return {
Expand All @@ -15,7 +19,8 @@ module.exports = async function (config) {
extraMetadata: {
name: 'mapeo-icca',
productName,
variant: 'icca'
variant: 'icca',
mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN
},
publish: [
{
Expand Down
10 changes: 7 additions & 3 deletions webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const Dotenv = require('dotenv-webpack')

module.exports = {
entry: {
Expand All @@ -17,8 +18,6 @@ module.exports = {
'mime-db',
'../package.json'
],
// plugins: [new LiveReloadPlugin()],
// plugins: [new BundleAnalyzerPlugin()],
output: {
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
Expand Down Expand Up @@ -51,5 +50,10 @@ module.exports = {
loader: 'url-loader'
}
]
}
},
plugins: [
new Dotenv({
systemvars: true
})
]
}
Loading