Skip to content

Commit

Permalink
Fb/json output (#90)
Browse files Browse the repository at this point in the history
* add json output flag arg for long list commands

* hdill output is coming through

* cli singleton logger

* naive singleton logger rollout

* prepare for logger level switching

* some newline consistency

* stop wierd handling of array results

* rely on result handling in cli

* make lint non-fixing by default

* slowly adopt singleton logger

* slowly adopt singleton logger 2

* slowly adopt singleton logger 3

* slowly adopt singleton logger 4

* slowly adopt singleton logger 5

* slowly adopt singleton logger 6

* remove redundant vars

* extend json to regular list commands

* add docs for json flag arg

* add json for uaa

* consistency fix

* fix tests 1

* fix tests 2

* shorter wording

* consistency fix

* slightly different wording

* re-add force flag to bypass validation

* add test for force flag bypass

* wippedy wip wip rewrite nock stuff to account for makeOneTime

* wippedy wip wip rewrite nock stuff to account for makeOneTime 2

* bug detected

* more progress towards separated nock playback record

* more progress towards separated nock playback record 2

* more progress towards separated nock playback record 3

* more progress towards separated nock playback record 4

* more progress towards separated nock playback record 5

* more progress towards separated nock playback record 6

* more progress towards separated nock playback record 7

* more progress towards separated nock playback record 8

* more progress towards separated nock playback record 9

* more progress towards separated nock playback record 10

* prettier config

* more unnecessary scripts

* polish pass over jest config

* jest config consistency

* move jest clear all mocks to the general configuration

* add cloc script

* wrong code order
  • Loading branch information
rlindner81 authored Dec 3, 2024
1 parent 32c1008 commit c354c2d
Show file tree
Hide file tree
Showing 70 changed files with 130,596 additions and 72,680 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
node-version: 18
cache: npm
- run: npm ci --package-lock
- run: npm run lint:ci
- run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/main-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
node-version: 18
cache: npm
- run: npm ci --package-lock
- run: npm run lint:ci
- run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: npm ci --package-lock
- run: npm test
- run: npm run lint:ci
- run: npm run lint
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ temp/

# npm package
*.tgz

# jest
coverage/
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ node_modules/
package-lock.json
temp/

test/__nock-fixtures__
test-nock-record/__nock-fixtures__

docs/vendor/
docs/_site/
Expand Down
1 change: 1 addition & 0 deletions docs/cap-multitenancy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Commands for this area are:
... [TENANT] filter list for tenant id or subdomain
... --auto-undeploy upgrade with auto undeploy
... --time list includes timestamps
... --json list in json
~ are read-only commands
* are potentially _dangerous_ commands
Expand Down
1 change: 1 addition & 0 deletions docs/hana-management/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Commands for this area are:
... [PARAMS] create binding with custom parameters
... --reveal show passwords
... --time list includes timestamps
... --json list in json
~ are read-only commands
* are potentially _dangerous_ commands
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ commands:
~ uaasu --uaa-service-user SERVICE USERNAME PASSWORD [TENANT] obtain service token for username password
... [TENANT] obtain token for tenant, fallback to paas tenant
... --decode decode result token
... --json output in json
... --userinfo add detailed user info for passcode or username
=== tenant registry (reg) ===
Expand All @@ -81,6 +82,7 @@ commands:
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --json list in json
... --skip-unchanged skip update for unchanged dependencies
... --only-stale only update subscriptions that have not changed today
... --only-failed only update subscriptions with UPDATE_FAILED state
Expand All @@ -97,6 +99,7 @@ commands:
... [TENANT] filter list for tenant id or subdomain
... --auto-undeploy upgrade with auto undeploy
... --time list includes timestamps
... --json list in json
=== hana management (hdi) ===
~ hdil --hdi-list [TENANT_ID] list all hdi container instances
Expand All @@ -112,6 +115,7 @@ commands:
... [PARAMS] create binding with custom parameters
... --reveal show passwords
... --time list includes timestamps
... --json list in json
=== server diagnostic (srv) ===
~ srv --server-info call server /info
Expand Down
1 change: 1 addition & 0 deletions docs/tenant-registry/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Commands for this area are:
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --json list in json
... --skip-unchanged skip update for unchanged dependencies
... --only-stale only update subscriptions that have not changed today
... --only-failed only update subscriptions with UPDATE_FAILED state
Expand Down
1 change: 1 addition & 0 deletions docs/user-authentication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Commands for this area are:
~ uaasu --uaa-service-user SERVICE USERNAME PASSWORD [TENANT] obtain service token for username password
... [TENANT] obtain token for tenant, fallback to paas tenant
... --decode decode result token
... --json output in json
... --userinfo add detailed user info for passcode or username
~ are read-only commands
Expand Down
19 changes: 19 additions & 0 deletions jest-nock-record.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// NOTE: Inline Snapshots are not supported when using Prettier 3.0.0 or above
// https://jestjs.io/docs/configuration/#prettierpath-string
prettierPath: null,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: false,

// The test environment that will be used for testing
testEnvironment: "node",

// The glob patterns Jest uses to detect test files
testMatch: ["<rootDir>/test-nock-record/**/?(*.)+(spec|test).[tj]s?(x)"],
};
173 changes: 15 additions & 158 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,180 +8,37 @@ module.exports = {
// https://jestjs.io/docs/configuration/#prettierpath-string
prettierPath: null,

// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// Respect "browser" field in package.json when resolving modules
// browser: false,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/5w/hbm2r3cj1mg0gjh0bhl5g62m7k7zzc/T/jest_478h64",

// Automatically clear mock calls and instances between every test
// clearMocks: false,
clearMocks: true,

// TODO: after removing deprecated code for instance manager and legacy cds-mtx, this will be enabled
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ["src/**/*.js", "!src/**/cli.js"],

// The directory where Jest should output its coverage files
// coverageDirectory: undefined,
collectCoverageFrom: ["src/**/*.js"],

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ["/node_modules/", "/bin/"],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: ["text"],
coverageReporters: ["lcov"],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],

// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
},
},

// The test environment that will be used for testing
testEnvironment: "node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
testMatch: ["<rootDir>/test/**/?(*.)+(spec|test).[tj]s?(x)"],
};
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@
"test:remove-inline-snapshots": "npx replace '\\.toMatchInlineSnapshot\\(\\s*`[\\s\\S]*?`\\s*\\);' '.toMatchInlineSnapshot();' test -r --include='*.test.js'",
"test:record": "npm run test:record:reg && npm run test:record:cds && npm run test:record:hdi",
"test:update": "jest --updateSnapshot",
"test:reg": "jest test/tenantRegistry.nock.test.js",
"test:cds": "jest test/capMultitenancy.nock.test.js",
"test:hdi": "jest test/hanaManagement.nock.test.js",
"test:record:reg": "npx cross-env NOCK_MODE=record jest test/tenantRegistry.nock.test.js --runInBand --updateSnapshot && jest test/tenantRegistry.nock.test.js --runInBand --updateSnapshot",
"test:record:cds": "npx cross-env NOCK_MODE=record jest test/capMultitenancy.nock.test.js --runInBand --updateSnapshot && jest test/capMultitenancy.nock.test.js --runInBand --updateSnapshot",
"test:record:hdi": "npx cross-env NOCK_MODE=record jest test/hanaManagement.nock.test.js --runInBand --updateSnapshot && jest test/hanaManagement.nock.test.js --runInBand --updateSnapshot",
"lint": "npm run eslint && npm run prettier",
"lint:ci": "npm run eslint:ci && npm run prettier:ci",
"eslint": "eslint --fix .",
"eslint:ci": "eslint .",
"prettier": "prettier --write --log-level error .",
"prettier:ci": "prettier --check .",
"test:record:reg": "jest --runInBand --config jest-nock-record.config.js test-nock-record/tenantRegistry.nock.test.js",
"test:record:cds": "jest --runInBand --config jest-nock-record.config.js test-nock-record/capMultitenancy.nock.test.js",
"test:record:hdi": "jest --runInBand --config jest-nock-record.config.js test-nock-record/hanaManagement.nock.test.js",
"lint": "npm run prettier && npm run eslint",
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
"eslint": "eslint .",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "prettier \"**/*.{js,json,md,yml,yaml}\" . --check",
"prettier:fix": "npm run prettier -- --log-level error --write",
"pack": "npm pack",
"docs": "cd docs && bundle exec jekyll serve",
"docs:install": "cd docs && npx shx rm -rf vendor Gemfile.lock && bundle install",
"cloc": "npx cloc --vcs=git src",
"upgrade-lock": "npx shx rm -rf package-lock.json node_modules && npm i --package-lock && npm run patch"
},
"engines": {
Expand Down
Loading

0 comments on commit c354c2d

Please sign in to comment.