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

feat: general configuration, application layout and directory structure #1

Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# https://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
open-pull-requests-limit: 5
versioning-strategy: 'increase'
4 changes: 4 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
titleOnly: false
commitsOnly: false
titleAndCommits: true
allowMergeCommits: true
145 changes: 145 additions & 0 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: 'dhis2: verify (app)'

on: push

concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true

env:
GIT_AUTHOR_NAME: '@dhis2-bot'
GIT_AUTHOR_EMAIL: 'apps@dhis2.org'
GIT_COMMITTER_NAME: '@dhis2-bot'
GIT_COMMITTER_EMAIL: 'apps@dhis2.org'
GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}}
CI: true
D2_VERBOSE: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- uses: actions/upload-artifact@v2
with:
name: app-build
path: |
**/build
!**/node_modules
retention-days: 1

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile

- name: Lint
run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile

# Can be removed if translations aren't required for tests, or if not using the App Platform
- name: Generate translations
run: yarn d2-app-scripts i18n generate

- name: Test
run: yarn test

#e2e:
# runs-on: ubuntu-latest
# if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
#
# strategy:
# fail-fast: false
# matrix:
# containers: [1, 2, 3, 4]
#
# steps:
# - name: Checkout
# uses: actions/checkout@v2
#
# - uses: actions/setup-node@v1
# with:
# node-version: 12.x
#
# - name: End-to-End tests
# uses: cypress-io/github-action@v2
# with:
# # This should be a command that serves the app.
# start: yarn d2-app-scripts start
# wait-on: 'http://localhost:3000'
# wait-on-timeout: 300
# record: true
# parallel: true
# env:
# BROWSER: none
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# CYPRESS_dhis2BaseUrl: https://debug.dhis2.org/dev
# CYPRESS_dhis2ApiVersion: 37
# CYPRESS_networkMode: stub

publish:
runs-on: ubuntu-latest
needs: [build, lint, test] # add e2e if you use it
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
steps:
- uses: actions/checkout@v2
with:
token: ${{env.GH_TOKEN}}

- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: actions/download-artifact@v2
with:
name: app-build

- uses: dhis2/deploy-build@master
with:
# uncomment following line for monorepo apps:
#cwd: ./packages/app
build-dir: build/app
github-token: ${{ env.GH_TOKEN }}

release:
runs-on: ubuntu-latest
needs: [publish]
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
steps:
- uses: actions/checkout@v2
with:
token: ${{env.GH_TOKEN}}

- uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Publish release to GitHub
run: npx @dhis2/cli-utils release
19 changes: 19 additions & 0 deletions .ls-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ls:
./**/{src,cypress,lib}:
.css: kebab-case
.module.css: kebab-case
.feature: kebab-case
.js: kebab-case
.stories.js: kebab-case
.stories.e2e.js: kebab-case
.styles.js: kebab-case
.test.js: kebab-case
.jsx: kebab-case
.ts: kebab-case
.tsx: kebab-case
.d.ts: kebab-case

ignore:
- node_modules
- .d2
- build
13 changes: 13 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
/*
* The code snippet below was generated by @dhis2/cli-style.
* There is nothing wrong with it, but somehow the VSCode
* prettier plugin can't work with it. As a temporary hack
* we use the theoretically equivalent code below, that doesn't
* break the plugin.

const { config } = require('@dhis2/cli-style')

module.exports = {
...require(config.prettier),
}

*/

const prettierConfig = require('@dhis2/cli-style/config/prettier.config.js')

module.exports = { ...prettierConfig }
10 changes: 10 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[main]
host = https://www.transifex.com
lang_map = fa_AF: prs, uz@Cyrl: uz, uz@Latn: uz_Latn

[app-approval-app.en-pot]
file_filter = i18n/<lang>.po
minimum_perc = 0
source_file = i18n/en.pot
source_lang = en
type = PO
5 changes: 3 additions & 2 deletions d2.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
type: 'app',

title: 'Data Approval App',
coreApp: true,
entryPoints: {
app: './src/App.js',
app: './src/app/index.js',
},
}
19 changes: 19 additions & 0 deletions i18n/en.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2021-06-15T13:56:19.937Z\n"
"PO-Revision-Date: 2021-06-15T13:56:19.937Z\n"

msgid "Not authorized"
msgstr "Not authorized"

msgid ""
"You don't have access to the Data Approval App. Contact a system "
"administrator to request access."
msgstr ""
"You don't have access to the Data Approval App. Contact a system "
"administrator to request access."
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
setupFilesAfterEnv: ['<rootDir>/src/test-utils/setup-tests.js'],
collectCoverageFrom: ['src/**/*.{js,jsx}', '!src/{setupTests.js}'],
coveragePathIgnorePatterns: ['/node_modules/', '/src/locales/'],
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy',
},
}
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
"private": true,
"scripts": {
"build": "d2-app-scripts build",
"deploy": "d2-app-scripts deploy",
"format": "d2-style apply",
"lint": "d2-style check",
"start": "d2-app-scripts start",
"test": "d2-app-scripts test",
"deploy": "d2-app-scripts deploy"
"test": "d2-app-scripts test"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^6.2.0",
"@dhis2/cli-style": "^8.3.0"
"@dhis2/cli-style": "^8.4.1",
"@testing-library/react-hooks": "^7.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"identity-obj-proxy": "^3.0.0"
},
"dependencies": {
"@dhis2/app-runtime": "^2.8.0"
"@dhis2/app-runtime": "^2.8.0",
"prop-types": "^15.7.2",
"query-string": "^7.0.0",
"use-query-params": "^1.2.2"
}
}
31 changes: 0 additions & 31 deletions src/App.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.module.css

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

5 changes: 5 additions & 0 deletions src/action-bar/action-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react'

const ActionBar = () => <pre>ActionBar placeholder</pre>

export { ActionBar }
1 change: 1 addition & 0 deletions src/action-bar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ActionBar } from './action-bar.js'
32 changes: 32 additions & 0 deletions src/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CssVariables } from '@dhis2/ui'
import React from 'react'
import { QueryParamProvider } from 'use-query-params'
import { ActionBar } from '../action-bar'
import { AuthWall } from '../auth'
import { ContextSelector } from '../context-selector'
import { CurrentUserProvider } from '../current-user'
import { DataWorkspace } from '../data-workspace'
import { Layout } from './layout.js'

const App = () => (
<QueryParamProvider>
<CssVariables spacers colors theme />
<CurrentUserProvider>
<AuthWall>
<Layout.Container>
<Layout.Top>
<ContextSelector />
</Layout.Top>
<Layout.Content>
<DataWorkspace />
</Layout.Content>
<Layout.Bottom>
<ActionBar />
</Layout.Bottom>
</Layout.Container>
</AuthWall>
</CurrentUserProvider>
</QueryParamProvider>
)

export { App }
9 changes: 9 additions & 0 deletions src/app/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { shallow } from 'enzyme'
import React from 'react'
import { App } from './app'

describe('<App>', () => {
it('renders without errors', () => {
shallow(<App />)
})
})
Loading