Skip to content

Commit

Permalink
Merge pull request #1575 from ONEARMY/master
Browse files Browse the repository at this point in the history
🤖 Release PR
  • Loading branch information
thisislawatts authored Mar 30, 2022
2 parents daa2182 + 479bd8d commit 9991ae3
Show file tree
Hide file tree
Showing 280 changed files with 3,347 additions and 2,989 deletions.
34 changes: 17 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ aliases:
# https://circleci.com/docs/2.0/yarn/
# when lock file changes, use increasingly general patterns to restore cache (also need to change `save_cache` path)
# NOTE - if changing base image or received cache permission denied may need to bump version v3->v4 or similar (clears after 15d)
- yarn-packages-v12-{{ checksum "yarn.lock" }}
- yarn-packages-v12-
- v14-yarn-packages-{{ checksum "yarn.lock" }}
- v14-yarn-packages-
- &install_packages
run:
name: Install Packages
Expand All @@ -59,7 +59,7 @@ aliases:
# - ~/.yarn/berry/cache
# local cache location
- ~/project/.yarn/cache
key: yarn-packages-v12-{{ checksum "yarn.lock" }}
key: v14-yarn-packages-{{ checksum "yarn.lock" }}

- &filter_only_production
filters:
Expand Down Expand Up @@ -221,18 +221,18 @@ jobs:
- image: timbru31/java-node:alpine-12
resource_class: small
steps:
- setup_repo
- checkout
# - *restore_yarn_cache
- run: yarn && yarn build:components && yarn workspace functions build && yarn workspace functions emulator:test

# Create a production build
# NOTE - not currently used in test workflow as different build_env required for each machine
test_unit:
docker: *docker
resource_class: small
steps:
# whilst checkout-install could be persisted from previous step, that is less efficient than just using caching
- checkout
- *restore_yarn_cache
# - *restore_yarn_cache
- run:
name: Install dependencies
command: yarn workspaces focus one-army-community-platform
Expand All @@ -248,7 +248,7 @@ jobs:
steps:
# whilst checkout-install could be persisted from previous step, that is less efficient than just using caching
- checkout
- *restore_yarn_cache
# - *restore_yarn_cache
- run:
name: Install dependencies
command: yarn workspaces focus one-army-community-platform
Expand Down Expand Up @@ -394,21 +394,21 @@ workflows:
branches:
ignore:
- production
- test_functions:
name: 'Cloud Function tests'
context: build-context
requires:
- 'Lint commits'
filters:
branches:
ignore:
- production
# - test_functions:
# name: 'Cloud Function tests'
# context: build-context
# requires:
# - 'Lint commits'
# filters:
# branches:
# ignore:
# - production
- test_e2e:
name: e2e-<< matrix.CI_BROWSER >>-<< matrix.CI_NODE >>
requires:
- 'Build Application'
- 'Unit tests'
- 'Cloud Function tests'
# - 'Cloud Function tests'
- 'Build Storybook'
context:
- e2e-tests
Expand Down
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ functions-cron
build
cypress
lib
storybook-static
storybook-static
dist
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
.firebase
.firebase
storybook-static
dist
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![react](https://badges.aleen42.com/src/react.svg)](https://reactjs.org/docs/getting-started.html)
[![Style: Styled-components](https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e)](https://github.com/styled-components/styled-components)

# Contribution Guidelines

Expand Down Expand Up @@ -33,7 +32,7 @@ This project and everyone participating in it is governed by the [Code of Conduc

### Frontend

The platform is built in **React** and [Typescript](https://www.typescriptlang.org/docs/handbook/basic-types.html) for typing and consistency, [styled-components](https://www.styled-components.com/) for reusability and component based styling.
The platform is built in **React** and [Typescript](https://www.typescriptlang.org/docs/handbook/basic-types.html) for typing and consistency, [Emotion](https://emotion.sh/) for reusability and component based styling.
We created a frontend guide to explain our choices and best practice in building the One Army interface. This guide is available in [the wiki](https://github.com/ONEARMY/community-platform/wiki/Frontend).

### Backend
Expand Down
10 changes: 5 additions & 5 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {UserConfig} from '@commitlint/types';
import type { UserConfig } from '@commitlint/types'
import path from 'path'

const Configuration: UserConfig = {
const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
/** Add optional custom formatter */
formatter: path.resolve(__dirname,'commitlint.format.ts'),
formatter: path.resolve(__dirname, 'commitlint.format.ts'),
/** Add optional override rules (https://www.npmjs.com/package/@commitlint/config-conventional) */
// rules: {},
helpUrl:
'run `yarn commit` for interactive prompt or see examples at\nhttps://www.conventionalcommits.org',
'run `yarn commit` for interactive prompt or see examples at\nhttps://www.conventionalcommits.org',
// Interactive prompts, called via `yarn commit`
prompt: {
settings: {},
Expand Down Expand Up @@ -121,4 +121,4 @@ const Configuration: UserConfig = {
},
}

module.exports = Configuration;
module.exports = Configuration
17 changes: 9 additions & 8 deletions commitlint.format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { Formatter, FormattableReport } from '@commitlint/types'

// Custom formatter for commitlint message
const formatter: Formatter = function (report, options) {
const { results, valid, } = report as IFormatReport
const { results, valid } = report as IFormatReport
if (results && !valid) {
console.log("\nCommit needs to be formatted as conventional commit")
console.log("\n<type>[optional scope]: <description>\n")
console.log('\nCommit needs to be formatted as conventional commit')
console.log('\n<type>[optional scope]: <description>\n')
for (const result of results) {
if (result.errors) {
for (const error of result.errors) {
Expand All @@ -14,17 +14,18 @@ const formatter: Formatter = function (report, options) {
}
}
}

}
console.log("\n")
console.log('\n')
console.log(options.helpUrl)
console.log("\n")
console.log('\n')
return ''
}

module.exports = formatter

// Fix type definition for formattable report
interface IFormatReport extends FormattableReport {
errorCount: number, valid: boolean, warningCount: number
}
errorCount: number
valid: boolean
warningCount: number
}
40 changes: 22 additions & 18 deletions functions-cron/app.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
const express = require('express');
const PubSub = require('@google-cloud/pubsub');
const express = require('express')
const PubSub = require('@google-cloud/pubsub')

// Create a new PubSub client using the GOOGLE_CLOUD_PROJECT
// environment variable. This is automatically set to the correct
// value when running on AppEngine.
const pubsubClient = new PubSub({
projectId: process.env.GOOGLE_CLOUD_PROJECT
});
projectId: process.env.GOOGLE_CLOUD_PROJECT,
})

const app = express();
const app = express()

// For any request to /public/{some_topic}, push a simple
// PubSub message to that topic.
app.get('/publish/:topic', async (req, res) => {
const topic = req.params['topic'];
const topic = req.params['topic']

try {
await pubsubClient.topic(topic)
.publisher()
.publish(Buffer.from('test'));
await pubsubClient.topic(topic).publisher().publish(Buffer.from('test'))

res.status(200).send('Published to ' + topic).end();
res
.status(200)
.send('Published to ' + topic)
.end()
} catch (e) {
res.status(500).send('' + e).end();
res
.status(500)
.send('' + e)
.end()
}
});
})

// Index page, just to make it easy to see if the app is working.
app.get('/', (req, res) => {
res.status(200).send('[functions-cron]: Hello, world!').end();
});
res.status(200).send('[functions-cron]: Hello, world!').end()
})

// Start the server
const PORT = process.env.PORT || 6060;
const PORT = process.env.PORT || 6060
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
console.log(`App listening on port ${PORT}`)
console.log('Press Ctrl+C to quit.')
})
8 changes: 4 additions & 4 deletions functions/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { InitialOptionsTsJest } from 'ts-jest/dist/types';
import type { InitialOptionsTsJest } from 'ts-jest/dist/types'

const config: InitialOptionsTsJest = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ["<rootDir>"],
roots: ['<rootDir>'],
modulePathIgnorePatterns: ['<rootDir>/dist/'],
setupFiles: ['<rootDir>/scripts/set-up-environment-variables.ts']
setupFiles: ['<rootDir>/scripts/set-up-environment-variables.ts'],
}

export default config;
export default config
10 changes: 5 additions & 5 deletions functions/scripts/emulator/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (require.main === module) {
export function emulatorSeed() {
const seedFiles = fs
.readdirSync(EMULATOR_SEED_FOLDER)
.filter(filename => filename.endsWith('.zip'))
.filter((filename) => filename.endsWith('.zip'))
if (seedFiles.length === 0) {
throw new Error('No seed files found in ' + EMULATOR_SEED_FOLDER)
}
Expand All @@ -32,16 +32,16 @@ export function emulatorSeed() {
const zipFile = fs.readFileSync(seedFilePath)
zip
.loadAsync(zipFile)
.then(contents => {
Object.values(contents.files).forEach(file => {
.then((contents) => {
Object.values(contents.files).forEach((file) => {
if (file.dir) {
const targetDir = path.resolve(EMULATOR_IMPORT_PATH, file.name)
fs.mkdirSync(targetDir, { recursive: true })
} else {
zip
.file(file.name)
.async('nodebuffer')
.then(data => {
.then((data) => {
fs.writeFileSync(
path.resolve(EMULATOR_IMPORT_PATH, file.name),
data,
Expand All @@ -56,7 +56,7 @@ export function emulatorSeed() {
EMULATOR_IMPORT_PATH,
)
})
.catch(err => {
.catch((err) => {
console.error(err)
process.exit(1)
})
Expand Down
20 changes: 16 additions & 4 deletions functions/scripts/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ export const EMULATOR_IMPORT_FOLDER = 'data/emulated'
export const EMULATOR_EXPORT_FOLDER = 'data/exported'

// For custom scripts full paths user
export const EMULATOR_SEED_PATH = path.resolve(FUNCTIONS_DIR, EMULATOR_SEED_FOLDER)
export const EMULATOR_IMPORT_PATH = path.resolve(FUNCTIONS_DIR, EMULATOR_IMPORT_FOLDER)
export const EMULATOR_EXPORT_PATH = path.resolve(FUNCTIONS_DIR, EMULATOR_EXPORT_FOLDER)
export const EMULATOR_SEED_PATH = path.resolve(
FUNCTIONS_DIR,
EMULATOR_SEED_FOLDER,
)
export const EMULATOR_IMPORT_PATH = path.resolve(
FUNCTIONS_DIR,
EMULATOR_IMPORT_FOLDER,
)
export const EMULATOR_EXPORT_PATH = path.resolve(
FUNCTIONS_DIR,
EMULATOR_EXPORT_FOLDER,
)

// For compiling src folder
export const PLATFORM_ROOT_PATH = path.resolve(FUNCTIONS_DIR, '..')
export const PLATFORM_LIB_PATH = path.resolve(PLATFORM_ROOT_PATH, 'lib')
export const PLATFORM_TSCONFIG_TYPES_PATH = path.resolve(PLATFORM_ROOT_PATH, 'tsconfig.src-types.json')
export const PLATFORM_TSCONFIG_TYPES_PATH = path.resolve(
PLATFORM_ROOT_PATH,
'tsconfig.src-types.json',
)
8 changes: 4 additions & 4 deletions functions/scripts/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function main() {
// CLI: concurrently --kill-others-on-fail --names \"emulator,functions\" -c \"blue,magenta\" \"yarn serve:emulated\" \"yarn watch\"

compileAndWatchFunctions()
.then(webpackWatcher => {
.then((webpackWatcher) => {
if (webpackWatcher) {
// start emulator only after compiler running (to pass close callback)
startEmulator(webpackWatcher)
}
})
.catch(err => {
.catch((err) => {
console.error(err)
process.exit(1)
})
Expand Down Expand Up @@ -57,7 +57,7 @@ async function compileAndWatchFunctions(): Promise<webpack.Compiler.Watching> {
},
)
// Wait for the first build to be completed before resolving (to ensure dist folder populated)
return new Promise(resolve => {
return new Promise((resolve) => {
compiler.hooks.afterCompile.tap('build complete', () => {
resolve(watcher)
})
Expand Down Expand Up @@ -104,7 +104,7 @@ function startEmulator(functionsCompiler: webpack.Compiler.Watching) {
env,
})
// listen for close and kill functions compiler if error thrown
child.on('close', code => {
child.on('close', (code) => {
if (code === 1) {
console.error('[Emulator Error]')
functionsCompiler.close(() =>
Expand Down
1 change: 0 additions & 1 deletion functions/src/Firebase/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ else {
admin.initializeApp()
}


export const firebaseAdmin = admin

// this is automatically populated by firebase
Expand Down
Loading

0 comments on commit 9991ae3

Please sign in to comment.