Skip to content

Commit

Permalink
fix(dist): import module error
Browse files Browse the repository at this point in the history
1.  fix(dist): import module

    Update outdated rollup-plugins.

    The dev-dependency rollup-plugin-node-resolve
    introduced a breaking change. Once the mainFields
    property had values, rollup.js worked again.

    Also set package.json#files to "dist", which
    ensures the distribution if much smaller, e.g.,

    Also set package.json#files to "dist", which
    ensures the distribution if much smaller.

    Introduce two new npm-scripts to make pre-release
    testing easier:

    1. bundle:clean - removes ./dist/ and *.tgz
    2. prebundle: calls bundle:clean
    3. postbundle - calls npm pack

    #38

2.  build(env): add config values

    Add missing ENV VARS:

    - CODACY_PROJECT_TOKEN=
    - C_TEST_REPORTER_ID=

    #38

3.  build(pkg): update all dependencies

    Update all dependencies while updating
    rollup-plugins for issue #38.

    #35
    #36
    #37
    #39
  • Loading branch information
gregswindle authored May 21, 2019
1 parent ba7287b commit c22a8ef
Show file tree
Hide file tree
Showing 22 changed files with 2,858 additions and 1,858 deletions.
22 changes: 20 additions & 2 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
## 🚫 Your production database should have a different password
## 🚫 than your development database.

# Codacy

CODACY_PROJECT_TOKEN=

# CodeClimate

CC_TEST_REPORTER_ID=

#
# Product manifest (package.json) variables
#

NODE_ENV=development
NPM_PACKAGE_NAME=archetypes-rules
NPM_PACKAGE_VERSION=

Expand Down Expand Up @@ -69,16 +78,25 @@ JEST_JUNIT_ANCESTOR_SEPARATOR=
# @default "false"
JEST_USE_PATH_FOR_SUITE_NAME=

#
# RollupJS

BUILD=production
INCLUDE_DEPS=true

#
# SonarCloud variable defaults
#

# SonarCloud static code analysis

K8S_SECRET_SONAR_TOKEN=
SONAR_BRANCH_NAME=
SONAR_BRANCH_TARGET=master
SONAR_HOST_URL=https://sonarcloud.io
SONAR_ORGANIZATION=commonality
SONAR_PROJECT_DESCRIPTION=
SONAR_PROJECT_KEY=commonality_archetypes-rules
SONAR_PROJECT_NAME=archetypes-rules
SONAR_PROJECT_VERSION=$SONAR_PROJECT_VERSION
SONAR_PROJECT_VERSION=
SONAR_TOKEN=
K8S_SECRET_SONAR_TOKEN=
10 changes: 7 additions & 3 deletions .env.schema
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ JEST_JUNIT_ANCESTOR_SEPARATOR=
# @default "false"
JEST_USE_PATH_FOR_SUITE_NAME=

## Rollup.js

BUILD=
INCLUDE_DEPS=

#
# SonarCloud variables (CI/CD code analysis)
#
Expand All @@ -89,18 +94,17 @@ JEST_USE_PATH_FOR_SUITE_NAME=
# npm --loglevel silent run vars:git:branch:name
# @see https://sonarcloud.io/documentation/branches/overview/

SONAR_BRANCH_NAME=

# The default branch of the repository; it should almost always
# be "master".

SONAR_BRANCH_NAME=
K8S_SECRET_SONAR_TOKEN=
SONAR_BRANCH_TARGET=
SONAR_DATA_LOSS_SIGNATURES_TOKEN=
SONAR_HOST_URL=
SONAR_ORGANIZATION=
SONAR_PROJECT_DESCRIPTION=
SONAR_PROJECT_KEY=
SONAR_PROJECT_NAME=
SONAR_PROJECT_VERSION=
SONAR_TOKEN=
K8S_SECRET_SONAR_TOKEN=
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock = false
unsafe-perm = true
12 changes: 9 additions & 3 deletions lib/__tests__/env-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const envConfig = require('../env-config.js')
describe('envConfig', () => {
it('initializes all environment variables', () => {
const envConfigKeys = [
'CODACY_PROJECT_TOKEN',
'BUILD',
'CC_TEST_REPORTER_ID',
'CODACY_PROJECT_TOKEN',
'GH_TOKEN',
'GITHUB_TOKEN',
'GITLAB_ENDPOINT',
Expand All @@ -14,6 +15,7 @@ describe('envConfig', () => {
'GITLAB_RESOLVE_BODY_ONLY',
'GITLAB_RESOURCE',
'GITLAB_TOKEN',
'INCLUDE_DEPS',
'JEST_JUNIT_ANCESTOR_SEPARATOR',
'JEST_JUNIT_CLASSNAME',
'JEST_JUNIT_OUTPUT',
Expand All @@ -25,20 +27,24 @@ describe('envConfig', () => {
'JEST_USE_PATH_FOR_SUITE_NAME',
'K8S_SECRET_GITLAB_TOKEN',
'K8S_SECRET_SONAR_TOKEN',
'NODE_ENV',
'NPM_PACKAGE_NAME',
'NPM_PACKAGE_VERSION',
'NPM_TOKEN',
'SONAR_BRANCH_NAME',
'SONAR_BRANCH_TARGET',
'SONAR_HOST_URL',
'SONAR_ORGANIZATION',
'SONAR_PROJECT_DESCRIPTION',
'SONAR_PROJECT_KEY',
'SONAR_PROJECT_NAME',
'SONAR_PROJECT_VERSION',
'SONAR_TOKEN',
'SONAR_TOKEN_ARCHETYPES_RULES'
]
expect(envConfig).toBeDefined()
expect(Object.keys(envConfig).length)
.toBeLessThanOrEqual(envConfigKeys.length)
expect(Object.keys(envConfig).length).toBeLessThanOrEqual(
envConfigKeys.length
)
})
})
2 changes: 1 addition & 1 deletion lib/__tests__/invalid-rule-element-error.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const InvalidRuleElementError = require('../invalid-rule-element-error.js')
const InvalidRuleElementError = require('../errors/invalid-rule-element-error')

describe('InvalidRuleElementError', () => {
it('represents an invalid or unrecognized RuleElement instance', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/rule-element.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
const RuleElement = require('../rule-element.js')
const RuleElement = require('../rule-element/rule-element')

describe('RuleElement', () => {
describe('is an abstract representation of all properties common among Operators, Propositions, and Variables, with', () => {
Expand Down
16 changes: 9 additions & 7 deletions lib/env-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('debug')('dls:envConfig')
const debug = require('debug')('archetypes:rules:env-config')
const dotenvExtended = require('dotenv-extended')
const set = require('lodash.set')
const topairs = require('lodash.topairs')
const toPairs = require('lodash.topairs')

/**
* @description
Expand All @@ -14,17 +14,17 @@ const topairs = require('lodash.topairs')
* @see https://git.io/fhV1h
*/

const dotenvExtendedODefaults = {
assignToProcessEnv: false,
const dotenvExtendedDefaults = {
assignToProcessEnv: true,
defaults: '.env.defaults',
errorOnMissing: false,
errorOnMissing: true,
includeProcessEnv: true,
overrideProcessEnv: false,
path: '.env',
schema: '.env.schema'
}

const initEnvDefaults = (options = dotenvExtendedODefaults) => ({
const initEnvDefaults = (options = dotenvExtendedDefaults) => ({
parsed: Object.assign(dotenvExtended.load(options))
})

Expand All @@ -34,7 +34,7 @@ const sortEnvVars = (envDefaults) => {

}
}
const keyValuePairs = topairs(envDefaults.parsed).sort()
const keyValuePairs = toPairs(envDefaults.parsed).sort()
const envVarMap = new Map(keyValuePairs)
envVarMap.forEach((val, key) => {
set(dotenvVars.parsed, key, val)
Expand All @@ -49,4 +49,6 @@ const createEnvConfig = () => {

const envConfig = createEnvConfig()

debug(envConfig)

module.exports = envConfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assignTypeTo = require('./helpers/assign-type-to')
const assignTypeTo = require('../helpers/assign-type-to')

class InvalidRuleElementError extends TypeError {
constructor (message) {
Expand Down
3 changes: 2 additions & 1 deletion lib/factory/helpers/load-rule-elements.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { isOperator } = require('../../operator/operator')
const { isProposition } = require('../../proposition/proposition')
const { isVariable } = require('../../variable/variable')
const InvalidRuleElementError = require('../../invalid-rule-element-error')
/* eslint-disable-next-line max-len */
const InvalidRuleElementError = require('../../errors/invalid-rule-element-error')
const toArray = require('lodash.toarray')
const variableFactory = require('../../variable/variable-factory')

Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const ArrayVariable = require('./variable/array-variable')
const DateVariable = require('./variable/date-variable')
const ErrorVariable = require('./variable/error-variable')
const Fact = require('./rule-context/fact')
const InvalidRuleElementError = require('./invalid-rule-element-error')
const InvalidRuleElementError = require('./errors/invalid-rule-element-error')
const factory = require('./factory/factory')
const MapVariable = require('./variable/map-variable')
const NumberVariable = require('./variable/number-variable')
Expand All @@ -12,7 +12,7 @@ const Operator = require('./operator/operator')
const Proposition = require('./proposition/proposition')
const Rule = require('./rule/rule')
const RuleContext = require('./rule-context/rule-context')
const RuleElement = require('./rule-element')
const RuleElement = require('./rule-element/rule-element')
const RuleOverride = require('./rule-override/rule-override')
const RuleSet = require('./rule-set/rule-set')
const SetVariable = require('./variable/set-variable')
Expand Down
2 changes: 1 addition & 1 deletion lib/proposition/proposition.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const RuleElement = require('../rule-element')
const RuleElement = require('../rule-element/rule-element')
const { PROPOSITION } = require('../type-inspector/type-inspector')
const createRuleElementName = require('../helpers/create-rule-element-name')
const get = require('lodash.get')
Expand Down
4 changes: 2 additions & 2 deletions lib/rule-element.js → lib/rule-element/rule-element.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const anyTypePredicate = require('./helpers/any-type-predicate')
const assignTypeTo = require('./helpers/assign-type-to')
const anyTypePredicate = require('../helpers/any-type-predicate')
const assignTypeTo = require('../helpers/assign-type-to')
const ow = require('ow')

class RuleElement {
Expand Down
2 changes: 1 addition & 1 deletion lib/rule/helpers/__tests__/process.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */

const InvalidRuleElementError = require('../../../invalid-rule-element-error')
const InvalidRuleElementError = require('../../../errors/invalid-rule-element-error')
const Operator = require('../../../operator/operator')
const operatorType = require('../../../operator/operator-type')
const process = require('../process')
Expand Down
3 changes: 2 additions & 1 deletion lib/rule/helpers/process.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {isOperator} = require('../../operator/operator')
const isPropositionOrVariable = require('./is-proposition-or-variable')
const InvalidRuleElementError = require('../../invalid-rule-element-error')
/* eslint-disable-next-line max-len */
const InvalidRuleElementError = require('../../errors/invalid-rule-element-error')
const processOperator = require('./process-operator')
const processRuleElement = require('./process-rule-element')

Expand Down
2 changes: 1 addition & 1 deletion lib/type-inspector/__tests__/type-inspector.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const typeInspector = require('../type-inspector')
const types = require('../helpers/types.json')
const Proposition = require('../../proposition/proposition')
const RuleElement = require('../../rule-element')
const RuleElement = require('../../rule-element/rule-element')
const RuleSet = require('../../rule-set/rule-set')
const variableFactory = require('../../variable/variable-factory')

Expand Down
16 changes: 8 additions & 8 deletions lib/variable/__tests__/string-variable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ describe('StringVariable', () => {
})

describe('operator methods', () => {
describe('hasMaxLength', () => {
describe('exceedsMaxLength', () => {
it('determines whether the current value is less than or equal to a specific character count', () => {
const variable = new StringVariable('has-max-length', 'has-max-length')
let length = variable.value.length
const maxCharCount = new NumberVariable('max-char-count', length)
let proposition = variable.hasMaxLength(maxCharCount)
let proposition = variable.exceedsMaxLength(maxCharCount)
expect(proposition.value).toBe(true)

variable.value = 'This string value exceeds the maximum number allowed'
proposition = variable.hasMaxLength(maxCharCount)
proposition = variable.exceedsMaxLength(maxCharCount)
expect(proposition.value).toBe(false)
})

describe('when given anything other than a NumberVariable', () => {
it('throws an ArgumentError', () => {
expect(() => {
const thrower = new StringVariable('thrower')
thrower.hasMaxLength(
thrower.exceedsMaxLength(
new StringVariable('should-be', 'number-variable')
)
}).toThrow()
})
})
})
describe('hasMinLength', () => {
describe('lacksMinLength', () => {
it('determines whether the current value is greater than or equal to a given character count.', () => {
const variable = new StringVariable('has-min-length', 'has-min-length')

Expand All @@ -64,18 +64,18 @@ describe('StringVariable', () => {
variable.value.length
)

let proposition = variable.hasMinLength(minCharCount)
let proposition = variable.lacksMinLength(minCharCount)
expect(proposition.value).toBe(true)

variable.value = 'too-few'
proposition = variable.hasMinLength(minCharCount)
proposition = variable.lacksMinLength(minCharCount)
expect(proposition.value).toBe(false)
})
describe('when given anything other than a NumberVariable', () => {
it('throws an ArgumentError', () => {
expect(() => {
const thrower = new StringVariable('thrower')
thrower.hasMinLength(
thrower.lacksMinLength(
new StringVariable('should-be', 'a-number-variable')
)
}).toThrow()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */

const RuleElement = require('../../../rule-element')
const RuleElement = require('../../../rule-element/rule-element')
const isTypeNullVariable = require('../is-type-null-variable.js')

describe('isTypeNullVariable', () => {
Expand Down
Loading

0 comments on commit c22a8ef

Please sign in to comment.