Skip to content

Commit

Permalink
chore: update cli-style and reorder app-shell imports (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi authored Jan 13, 2021
1 parent 92f029a commit 0145e79
Show file tree
Hide file tree
Showing 36 changed files with 217 additions and 103 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
**/locales/index.js
cli/config/init.entrypoint.js
cli/config/init.App.test.js

2 changes: 1 addition & 1 deletion adapter/src/components/Alerts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { useAlerts } from '@dhis2/app-runtime'
import { AlertBar, AlertStack } from '@dhis2/ui'
import React from 'react'

export const Alerts = () => {
const alerts = useAlerts()
Expand Down
7 changes: 3 additions & 4 deletions adapter/src/components/AuthBoundary.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import { useDataQuery } from '@dhis2/app-runtime'

import { LoginModal } from './LoginModal'
import PropTypes from 'prop-types'
import React from 'react'
import { useLocale } from '../utils/useLocale'
import { LoadingMask } from './LoadingMask'
import { LoginModal } from './LoginModal'

const settingsQuery = {
userSettings: {
Expand Down
4 changes: 2 additions & 2 deletions adapter/src/components/FatalErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import styles from './styles/FatalErrorBoundary.style'

const translatedErrorHeading = i18n.t(
Expand Down
2 changes: 1 addition & 1 deletion adapter/src/components/LoadingMask.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Layer, CenteredContent, CircularLoader, layers } from '@dhis2/ui'
import React from 'react'

export const LoadingMask = () => (
<Layer translucent level={layers.alert}>
Expand Down
4 changes: 2 additions & 2 deletions adapter/src/components/LoginModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React, { useState } from 'react'
import i18n from '../locales'
import {
Modal,
ModalTitle,
Expand All @@ -8,6 +6,8 @@ import {
Button,
InputField,
} from '@dhis2/ui'
import React, { useState } from 'react'
import i18n from '../locales'
import { post } from '../utils/api'

const staticUrl = process.env.REACT_APP_DHIS2_BASE_URL
Expand Down
6 changes: 3 additions & 3 deletions adapter/src/components/ServerVersionProvider.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { Provider } from '@dhis2/app-runtime'
import PropTypes from 'prop-types'
import React, { useEffect, useState } from 'react'
import { get } from '../utils/api'
import { parseServerVersion } from '../utils/parseServerVersion'
import { LoadingMask } from './LoadingMask'
import { get } from '../utils/api'

export const ServerVersionProvider = ({ url, apiVersion, children }) => {
const [{ loading, error, systemInfo }, setState] = useState({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallow } from 'enzyme'
import React from 'react'
import { FatalErrorBoundary } from '../FatalErrorBoundary'
import { shallow } from 'enzyme'

const Something = () => {
// Placeholder
Expand Down
5 changes: 2 additions & 3 deletions adapter/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import { HeaderBar } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { Alerts } from './components/Alerts'
import { AuthBoundary } from './components/AuthBoundary'
import { FatalErrorBoundary } from './components/FatalErrorBoundary'
import { ServerVersionProvider } from './components/ServerVersionProvider'

import { styles } from './styles.js'

const App = ({ url, apiVersion, appName, children }) => (
Expand Down
2 changes: 1 addition & 1 deletion adapter/src/utils/useLocale.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'
import i18n from '@dhis2/d2-i18n'
import moment from 'moment'
import { useEffect } from 'react'

i18n.setDefaultNamespace('default')

Expand Down
1 change: 0 additions & 1 deletion cli/config/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')

const browserTargets = require('./.browserlistrc')
const jestTargets = { node: 'current' }

Expand Down
8 changes: 3 additions & 5 deletions cli/config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// rollup.config.js
const path = require('path')

const resolve = require('rollup-plugin-node-resolve')
const standardLibs = require('@dhis2/app-shell/package.json').dependencies
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const babel = require('rollup-plugin-babel')
const commonjs = require('rollup-plugin-commonjs')
const json = require('rollup-plugin-json')
const resolve = require('rollup-plugin-node-resolve')
const postcss = require('rollup-plugin-postcss')
const replace = require('rollup-plugin-replace')
const visualize = require('rollup-plugin-visualizer')

const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const extensions = ['.js', '.jsx', '.ts', '.tsx']

const standardLibs = require('@dhis2/app-shell/package.json').dependencies

// Exclude local app-shell dependencies
Object.entries(standardLibs).forEach(([dep, version]) => {
if (version.startsWith('file:') || version.startsWith('link:')) {
Expand Down
14 changes: 6 additions & 8 deletions cli/src/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const path = require('path')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')

const fs = require('fs-extra')
const path = require('path')

const i18n = require('../lib/i18n')
const bundleApp = require('../lib/bundleApp')
const { compile } = require('../lib/compiler')
const makePaths = require('../lib/paths')
const makeShell = require('../lib/shell')
const parseConfig = require('../lib/parseConfig')
const exitOnCatch = require('../lib/exitOnCatch')
const generateManifest = require('../lib/generateManifest')
const bundleApp = require('../lib/bundleApp')
const i18n = require('../lib/i18n')
const loadEnvFiles = require('../lib/loadEnvFiles')
const parseConfig = require('../lib/parseConfig')
const makePaths = require('../lib/paths')
const makeShell = require('../lib/shell')

const buildModes = ['development', 'production']

Expand Down
1 change: 0 additions & 1 deletion cli/src/commands/clean.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { reporter } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')

const makePaths = require('../lib/paths')

const handler = async ({ cwd }) => {
Expand Down
11 changes: 5 additions & 6 deletions cli/src/commands/deploy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const path = require('path')
const fs = require('fs-extra')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const FormData = require('form-data')
const fs = require('fs-extra')
const inquirer = require('inquirer')

const makePaths = require('../lib/paths')
const parseConfig = require('../lib/parseConfig')
const { createClient } = require('../lib/httpClient')
const { constructAppUrl } = require('../lib/constructAppUrl')
const { createClient } = require('../lib/httpClient')
const parseConfig = require('../lib/parseConfig')
const makePaths = require('../lib/paths')

const dumpHttpError = (message, response) => {
if (!response) {
Expand Down
3 changes: 1 addition & 2 deletions cli/src/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { reporter, chalk, exec } = require('@dhis2/cli-helpers-engine')
const path = require('path')
const { reporter, chalk, exec } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')
const gitignore = require('parse-gitignore')

const makePaths = require('../lib/paths')

const ignorePatterns = ['node_modules', '.d2', 'src/locales', 'build']
Expand Down
9 changes: 4 additions & 5 deletions cli/src/commands/start.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const detectPort = require('detect-port')

const i18n = require('../lib/i18n')
const { compile } = require('../lib/compiler')
const makePaths = require('../lib/paths')
const makeShell = require('../lib/shell')
const parseConfig = require('../lib/parseConfig')
const exitOnCatch = require('../lib/exitOnCatch')
const i18n = require('../lib/i18n')
const loadEnvFiles = require('../lib/loadEnvFiles')
const parseConfig = require('../lib/parseConfig')
const makePaths = require('../lib/paths')
const makeShell = require('../lib/shell')

const defaultPort = 3000

Expand Down
7 changes: 2 additions & 5 deletions cli/src/commands/test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const { reporter } = require('@dhis2/cli-helpers-engine')

const fs = require('fs-extra')

const makePaths = require('../lib/paths')
const { runCLI } = require('jest-cli')
const exitOnCatch = require('../lib/exitOnCatch')
const loadEnvFiles = require('../lib/loadEnvFiles')

const { runCLI } = require('jest-cli')
const makePaths = require('../lib/paths')

const handler = async ({
verbose,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib/bundleApp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs-extra')
const path = require('path')
const archiver = require('archiver')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const archiver = require('archiver')
const fs = require('fs-extra')

module.exports = (inDir, outFile) => {
return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/compiler/compile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const compileLibrary = require('./compileLibrary')
const compileApp = require('./compileApp')
const compileLibrary = require('./compileLibrary')

const compile = async ({
config,
Expand Down
8 changes: 3 additions & 5 deletions cli/src/lib/compiler/compileApp.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')

const path = require('path')
const fs = require('fs-extra')
const chokidar = require('chokidar')
const babel = require('@babel/core')

const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const chokidar = require('chokidar')
const fs = require('fs-extra')
const babelOptions = require('../../../config/app.babel.config')

const overwriteEntrypoint = async ({ config, paths }) => {
Expand Down
5 changes: 2 additions & 3 deletions cli/src/lib/compiler/compileLibrary.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const path = require('path')
const rollup = require('rollup')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')

const rollup = require('rollup')
const rollupConfigBuilder = require('../../../config/rollup.config')

const printRollupError = error => {
Expand Down
6 changes: 3 additions & 3 deletions cli/src/lib/i18n/extract.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fs = require('fs-extra')
const path = require('path')
const { checkDirectoryExists, walkDirectory, arrayEqual } = require('./helpers')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const scanner = require('i18next-scanner')
const fs = require('fs-extra')
const { i18nextToPot, gettextToI18next } = require('i18next-conv')
const scanner = require('i18next-scanner')
const { checkDirectoryExists, walkDirectory, arrayEqual } = require('./helpers')

const extract = async ({ input, output }) => {
const relativeInput = './' + path.relative(process.cwd(), input)
Expand Down
5 changes: 2 additions & 3 deletions cli/src/lib/i18n/generate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const fs = require('fs-extra')
const path = require('path')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const { gettextToI18next } = require('i18next-conv')
const fs = require('fs-extra')
const handlebars = require('handlebars')

const { gettextToI18next } = require('i18next-conv')
const { checkDirectoryExists } = require('./helpers')
const { langToLocale } = require('./locales')

Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/i18n/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')
const path = require('path')

const supportedExtensions = ['.js', '.jsx', '.ts', '.tsx']

Expand Down
5 changes: 2 additions & 3 deletions cli/src/lib/loadEnvFiles.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const fs = require('fs')
const dotenvExpand = require('dotenv-expand')
const dotenv = require('dotenv')

const { reporter } = require('@dhis2/cli-helpers-engine')
const dotenv = require('dotenv')
const dotenvExpand = require('dotenv-expand')

module.exports = (paths, NODE_ENV) => {
/*
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/parseConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const { defaultsDeep, has, isPlainObject } = require('lodash')
const fs = require('fs-extra')
const { defaultsDeep, has, isPlainObject } = require('lodash')
const parseAuthorString = require('parse-author')

const requiredConfigFields = {
Expand Down
5 changes: 2 additions & 3 deletions cli/src/lib/shell/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const fs = require('fs-extra')
const path = require('path')
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')

const currentShellVersion = require('@dhis2/app-shell/package.json').version
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')

const getShellVersion = shellDir => {
const shellPkg = path.join(shellDir, 'package.json')
Expand Down
1 change: 0 additions & 1 deletion cli/src/lib/shell/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { exec } = require('@dhis2/cli-helpers-engine')

const bootstrap = require('./bootstrap')
const getEnv = require('./env')

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-app/src/Alerter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import { useAlert } from '@dhis2/app-runtime'
import { InputField, Button } from '@dhis2/ui'
import React, { useState } from 'react'

export const Alerter = () => {
const [message, setMessage] = useState('')
Expand Down
6 changes: 3 additions & 3 deletions examples/simple-app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import i18n from './locales'
import moment from 'moment'
import { useDataQuery } from '@dhis2/app-runtime'
import moment from 'moment'
import React from 'react'
import { Alerter } from './Alerter.js'
import style from './App.style'
import i18n from './locales'

const query = {
me: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"devDependencies": {
"@dhis2/cli-style": "^7.2.1",
"@dhis2/cli-style": "^7.3.0",
"@dhis2/cli-utils-docsite": "^2.0.2",
"concurrently": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion shell/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/D2App/*
src/D2App/*
2 changes: 1 addition & 1 deletion shell/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import AppAdapter from '@dhis2/app-adapter'
import { Layer, layers, CenteredContent, CircularLoader } from '@dhis2/ui'
import React from 'react'

const D2App = React.lazy(() =>
import(/*webpackChunkName: 'app'*/ './D2App/app')
Expand Down
5 changes: 2 additions & 3 deletions shell/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { CssReset } from '@dhis2/ui'
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import * as serviceWorker from './serviceWorker'

import 'typeface-roboto'
import { CssReset } from '@dhis2/ui'
import * as serviceWorker from './serviceWorker'

ReactDOM.render(
<>
Expand Down
Loading

0 comments on commit 0145e79

Please sign in to comment.