diff --git a/pom.xml b/pom.xml index df49023265..383ed6186d 100644 --- a/pom.xml +++ b/pom.xml @@ -757,7 +757,7 @@ 4.0 - 1.3.0 + 1.4.0 9.2.10.v20150310 diff --git a/scm-it/pom.xml b/scm-it/pom.xml index 251fe4d957..3f518dd9fe 100644 --- a/scm-it/pom.xml +++ b/scm-it/pom.xml @@ -80,13 +80,6 @@ test - - javax - javaee-api - 7.0 - test - - org.glassfish javax.json diff --git a/scm-plugins/pom.xml b/scm-plugins/pom.xml index 16a74549e5..94d751dff7 100644 --- a/scm-plugins/pom.xml +++ b/scm-plugins/pom.xml @@ -113,92 +113,35 @@ sonia.scm.maven smp-maven-plugin - 1.0.0-alpha-2 + 1.0.0-alpha-3 true - true + + @scm-manager/ui-types + @scm-manager/ui-components + - - - fix-descriptor - process-resources - - fix-descriptor - - - - append-dependencies - process-classes - - append-dependencies - - - - - com.github.sdorra - buildfrontend-maven-plugin - - - ${nodejs.version} - - - YARN - ${yarn.version} - - false - - - - - install - process-resources - - install - - - - build - compile - - run - - - - + + com.github.sdorra + buildfrontend-maven-plugin + + + ${nodejs.version} + + + YARN + ${yarn.version} + + false + + - - release - - - - - sonia.maven - web-compressor - 1.4 - - - compile - - compress-directory - - - - - true - ${project.build.directory}/classes - - - - - - - doc diff --git a/scm-plugins/scm-git-plugin/.flowconfig b/scm-plugins/scm-git-plugin/.flowconfig index 7ede008602..b05e157358 100644 --- a/scm-plugins/scm-git-plugin/.flowconfig +++ b/scm-plugins/scm-git-plugin/.flowconfig @@ -4,5 +4,6 @@ [include] [libs] +./node_modules/@scm-manager/ui-components/flow-typed [options] diff --git a/scm-plugins/scm-git-plugin/flow-typed/npm/classnames_v2.x.x.js b/scm-plugins/scm-git-plugin/flow-typed/npm/classnames_v2.x.x.js deleted file mode 100644 index 2307243eeb..0000000000 --- a/scm-plugins/scm-git-plugin/flow-typed/npm/classnames_v2.x.x.js +++ /dev/null @@ -1,23 +0,0 @@ -// flow-typed signature: cf86673cc32d185bdab1d2ea90578d37 -// flow-typed version: 614bf49aa8/classnames_v2.x.x/flow_>=v0.25.x - -type $npm$classnames$Classes = - | string - | { [className: string]: * } - | false - | void - | null; - -declare module "classnames" { - declare module.exports: ( - ...classes: Array<$npm$classnames$Classes | $npm$classnames$Classes[]> - ) => string; -} - -declare module "classnames/bind" { - declare module.exports: $Exports<"classnames">; -} - -declare module "classnames/dedupe" { - declare module.exports: $Exports<"classnames">; -} diff --git a/scm-plugins/scm-git-plugin/flow-typed/npm/jest_v23.x.x.js b/scm-plugins/scm-git-plugin/flow-typed/npm/jest_v23.x.x.js deleted file mode 100644 index 23b66b07e5..0000000000 --- a/scm-plugins/scm-git-plugin/flow-typed/npm/jest_v23.x.x.js +++ /dev/null @@ -1,1108 +0,0 @@ -// flow-typed signature: f5a484315a3dea13d273645306e4076a -// flow-typed version: 7c5d14b3d4/jest_v23.x.x/flow_>=v0.39.x - -type JestMockFn, TReturn> = { - (...args: TArguments): TReturn, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: Array - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): void, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): void, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): void, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a string to use in test result output in place of "jest.fn()" to - * indicate which mock function is being referenced. - */ - mockName(name: string): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Accepts a value that will be returned whenever the mock function is called. - */ - mockReturnValue(value: TReturn): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: TReturn): JestMockFn, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) - */ - mockResolvedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) - */ - mockResolvedValueOnce(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) - */ - mockRejectedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) - */ - mockRejectedValueOnce(value: TReturn): JestMockFn> -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -/** - * Jest allows functions and classes to be used as test names in test() and - * describe() - */ -type JestTestName = string | Function; - -/** - * Plugin: jest-styled-components - */ - -type JestStyledComponentsMatcherValue = - | string - | JestAsymmetricEqualityType - | RegExp - | typeof undefined; - -type JestStyledComponentsMatcherOptions = { - media?: string; - modifier?: string; - supports?: string; -} - -type JestStyledComponentsMatchersType = { - toHaveStyleRule( - property: string, - value: JestStyledComponentsMatcherValue, - options?: JestStyledComponentsMatcherOptions - ): void, -}; - -/** - * Plugin: jest-enzyme - */ -type EnzymeMatchersType = { - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeEmptyRender(): void, - toBePresent(): void, - toContainReact(element: React$Element): void, - toExist(): void, - toHaveClassName(className: string): void, - toHaveHTML(html: string): void, - toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), - toHaveRef(refName: string): void, - toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), - toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), - toHaveTagName(tagName: string): void, - toHaveText(text: string): void, - toIncludeText(text: string): void, - toHaveValue(value: any): void, - toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void -}; - -// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers -type DomTestingLibraryType = { - toBeInTheDOM(): void, - toHaveTextContent(content: string): void, - toHaveAttribute(name: string, expectedValue?: string): void -}; - -// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers -type JestJQueryMatchersType = { - toExist(): void, - toHaveLength(len: number): void, - toHaveId(id: string): void, - toHaveClass(className: string): void, - toHaveTag(tag: string): void, - toHaveAttr(key: string, val?: any): void, - toHaveProp(key: string, val?: any): void, - toHaveText(text: string | RegExp): void, - toHaveData(key: string, val?: any): void, - toHaveValue(val: any): void, - toHaveCss(css: {[key: string]: any}): void, - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeHidden(): void, - toBeSelected(): void, - toBeVisible(): void, - toBeFocused(): void, - toBeInDom(): void, - toBeMatchedBy(sel: string): void, - toHaveDescendant(sel: string): void, - toHaveDescendantWithText(sel: string, text: string | RegExp): void -}; - - -// Jest Extended Matchers: https://github.com/jest-community/jest-extended -type JestExtendedMatchersType = { - /** - * Note: Currently unimplemented - * Passing assertion - * - * @param {String} message - */ - // pass(message: string): void; - - /** - * Note: Currently unimplemented - * Failing assertion - * - * @param {String} message - */ - // fail(message: string): void; - - /** - * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. - */ - toBeEmpty(): void; - - /** - * Use .toBeOneOf when checking if a value is a member of a given Array. - * @param {Array.<*>} members - */ - toBeOneOf(members: any[]): void; - - /** - * Use `.toBeNil` when checking a value is `null` or `undefined`. - */ - toBeNil(): void; - - /** - * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. - * @param {Function} predicate - */ - toSatisfy(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeArray` when checking if a value is an `Array`. - */ - toBeArray(): void; - - /** - * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. - * @param {Number} x - */ - toBeArrayOfSize(x: number): void; - - /** - * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. - * @param {Array.<*>} members - */ - toIncludeAllMembers(members: any[]): void; - - /** - * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. - * @param {Array.<*>} members - */ - toIncludeAnyMembers(members: any[]): void; - - /** - * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. - * @param {Function} predicate - */ - toSatisfyAll(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeBoolean` when checking if a value is a `Boolean`. - */ - toBeBoolean(): void; - - /** - * Use `.toBeTrue` when checking a value is equal (===) to `true`. - */ - toBeTrue(): void; - - /** - * Use `.toBeFalse` when checking a value is equal (===) to `false`. - */ - toBeFalse(): void; - - /** - * Use .toBeDate when checking if a value is a Date. - */ - toBeDate(): void; - - /** - * Use `.toBeFunction` when checking if a value is a `Function`. - */ - toBeFunction(): void; - - /** - * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. - * - * Note: Required Jest version >22 - * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same - * - * @param {Mock} mock - */ - toHaveBeenCalledBefore(mock: JestMockFn): void; - - /** - * Use `.toBeNumber` when checking if a value is a `Number`. - */ - toBeNumber(): void; - - /** - * Use `.toBeNaN` when checking a value is `NaN`. - */ - toBeNaN(): void; - - /** - * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. - */ - toBeFinite(): void; - - /** - * Use `.toBePositive` when checking if a value is a positive `Number`. - */ - toBePositive(): void; - - /** - * Use `.toBeNegative` when checking if a value is a negative `Number`. - */ - toBeNegative(): void; - - /** - * Use `.toBeEven` when checking if a value is an even `Number`. - */ - toBeEven(): void; - - /** - * Use `.toBeOdd` when checking if a value is an odd `Number`. - */ - toBeOdd(): void; - - /** - * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). - * - * @param {Number} start - * @param {Number} end - */ - toBeWithin(start: number, end: number): void; - - /** - * Use `.toBeObject` when checking if a value is an `Object`. - */ - toBeObject(): void; - - /** - * Use `.toContainKey` when checking if an object contains the provided key. - * - * @param {String} key - */ - toContainKey(key: string): void; - - /** - * Use `.toContainKeys` when checking if an object has all of the provided keys. - * - * @param {Array.} keys - */ - toContainKeys(keys: string[]): void; - - /** - * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. - * - * @param {Array.} keys - */ - toContainAllKeys(keys: string[]): void; - - /** - * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. - * - * @param {Array.} keys - */ - toContainAnyKeys(keys: string[]): void; - - /** - * Use `.toContainValue` when checking if an object contains the provided value. - * - * @param {*} value - */ - toContainValue(value: any): void; - - /** - * Use `.toContainValues` when checking if an object contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainValues(values: any[]): void; - - /** - * Use `.toContainAllValues` when checking if an object only contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainAllValues(values: any[]): void; - - /** - * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. - * - * @param {Array.<*>} values - */ - toContainAnyValues(values: any[]): void; - - /** - * Use `.toContainEntry` when checking if an object contains the provided entry. - * - * @param {Array.} entry - */ - toContainEntry(entry: [string, string]): void; - - /** - * Use `.toContainEntries` when checking if an object contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainAllEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. - * - * @param {Array.>} entries - */ - toContainAnyEntries(entries: [string, string][]): void; - - /** - * Use `.toBeExtensible` when checking if an object is extensible. - */ - toBeExtensible(): void; - - /** - * Use `.toBeFrozen` when checking if an object is frozen. - */ - toBeFrozen(): void; - - /** - * Use `.toBeSealed` when checking if an object is sealed. - */ - toBeSealed(): void; - - /** - * Use `.toBeString` when checking if a value is a `String`. - */ - toBeString(): void; - - /** - * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. - * - * @param {String} string - */ - toEqualCaseInsensitive(string: string): void; - - /** - * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. - * - * @param {String} prefix - */ - toStartWith(prefix: string): void; - - /** - * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. - * - * @param {String} suffix - */ - toEndWith(suffix: string): void; - - /** - * Use `.toInclude` when checking if a `String` includes the given `String` substring. - * - * @param {String} substring - */ - toInclude(substring: string): void; - - /** - * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. - * - * @param {String} substring - * @param {Number} times - */ - toIncludeRepeated(substring: string, times: number): void; - - /** - * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. - * - * @param {Array.} substring - */ - toIncludeMultiple(substring: string[]): void; -}; - -interface JestExpectType { - not: - & JestExpectType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - toBeCalled(): void; - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - toBeCalledTimes(number: number): void; - /** - * - */ - toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; - nthCalledWith(nthCall: number, ...args: Array): void; - /** - * - */ - toHaveReturned(): void; - toReturn(): void; - /** - * - */ - toHaveReturnedTimes(number: number): void; - toReturnTimes(number: number): void; - /** - * - */ - toHaveReturnedWith(value: any): void; - toReturnWith(value: any): void; - /** - * - */ - toHaveLastReturnedWith(value: any): void; - lastReturnedWith(value: any): void; - /** - * - */ - toHaveNthReturnedWith(nthCall: number, value: any): void; - nthReturnedWith(nthCall: number, value: any): void; - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - toBeCalledWith(...args: Array): void, - /** - * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called - * with specific arguments. - */ - toHaveBeenLastCalledWith(...args: Array): void, - lastCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression or string. - */ - toMatch(regexpOrString: RegExp | string): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object | Array): void, - /** - * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. - */ - toStrictEqual(value: any): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(name: string): void, - - toMatchInlineSnapshot(snapshot?: string): void, - toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void, - toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, -} - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Restores all mocks back to their original value. - */ - restoreAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn, TReturn>( - implementation?: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Returns the actual module instead of a mock, bypassing all checks on - * whether the module should receive a mock implementation or not. - */ - requireActual(moduleName: string): any, - /** - * Returns a mock module instead of the actual module, bypassing all checks - * on whether the module should be required normally or not. - */ - requireMock(moduleName: string): any, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - advanceTimersByTime(msToRun: number): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - * - * Renamed to `advanceTimersByTime`. - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, - /** - * Set the default timeout interval for tests and before/after hooks in milliseconds. - * Note: The default timeout interval is 5 seconds if this method is not called. - */ - setTimeout(timeout: number): JestObjectType -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before every test inside this context */ -declare function beforeEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; - -/** A context for grouping tests together */ -declare var describe: { - /** - * Creates a block that groups together several related tests in one "test suite" - */ - (name: JestTestName, fn: () => void): void, - - /** - * Only run this describe block - */ - only(name: JestTestName, fn: () => void): void, - - /** - * Skip running this describe block - */ - skip(name: JestTestName, fn: () => void): void -}; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - ( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - /** - * Only run this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - only( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): { - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - }, - /** - * Skip running this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - skip( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Run the test concurrently - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - concurrent( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void -}; -declare function fit( - name: JestTestName, - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -type JestPrettyFormatColors = { - comment: { close: string, open: string }, - content: { close: string, open: string }, - prop: { close: string, open: string }, - tag: { close: string, open: string }, - value: { close: string, open: string }, -}; - -type JestPrettyFormatIndent = string => string; -type JestPrettyFormatRefs = Array; -type JestPrettyFormatPrint = any => string; -type JestPrettyFormatStringOrNull = string | null; - -type JestPrettyFormatOptions = {| - callToJSON: boolean, - edgeSpacing: string, - escapeRegex: boolean, - highlight: boolean, - indent: number, - maxDepth: number, - min: boolean, - plugins: JestPrettyFormatPlugins, - printFunctionName: boolean, - spacing: string, - theme: {| - comment: string, - content: string, - prop: string, - tag: string, - value: string, - |}, -|}; - -type JestPrettyFormatPlugin = { - print: ( - val: any, - serialize: JestPrettyFormatPrint, - indent: JestPrettyFormatIndent, - opts: JestPrettyFormatOptions, - colors: JestPrettyFormatColors, - ) => string, - test: any => boolean, -}; - -type JestPrettyFormatPlugins = Array; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): - & JestExpectType - & JestPromiseType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - objectContaining(value: Object): Object, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): string, - stringMatching(value: string | RegExp): string, - not: { - arrayContaining: (value: $ReadOnlyArray) => Array, - objectContaining: (value: {}) => Object, - stringContaining: (value: string) => string, - stringMatching: (value: string | RegExp) => string, - }, -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jasmine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): Object, - stringMatching(value: string): string -}; diff --git a/scm-plugins/scm-git-plugin/flow-typed/npm/moment_v2.3.x.js b/scm-plugins/scm-git-plugin/flow-typed/npm/moment_v2.3.x.js deleted file mode 100644 index c2786e87fd..0000000000 --- a/scm-plugins/scm-git-plugin/flow-typed/npm/moment_v2.3.x.js +++ /dev/null @@ -1,331 +0,0 @@ -// flow-typed signature: 23b805356f90ad9384dd88489654e380 -// flow-typed version: e9374c5fe9/moment_v2.3.x/flow_>=v0.25.x - -type moment$MomentOptions = { - y?: number | string, - year?: number | string, - years?: number | string, - M?: number | string, - month?: number | string, - months?: number | string, - d?: number | string, - day?: number | string, - days?: number | string, - date?: number | string, - h?: number | string, - hour?: number | string, - hours?: number | string, - m?: number | string, - minute?: number | string, - minutes?: number | string, - s?: number | string, - second?: number | string, - seconds?: number | string, - ms?: number | string, - millisecond?: number | string, - milliseconds?: number | string -}; - -type moment$MomentObject = { - years: number, - months: number, - date: number, - hours: number, - minutes: number, - seconds: number, - milliseconds: number -}; - -type moment$MomentCreationData = { - input: string, - format: string, - locale: Object, - isUTC: boolean, - strict: boolean -}; - -type moment$CalendarFormat = string | ((moment: moment$Moment) => string); - -type moment$CalendarFormats = { - sameDay?: moment$CalendarFormat, - nextDay?: moment$CalendarFormat, - nextWeek?: moment$CalendarFormat, - lastDay?: moment$CalendarFormat, - lastWeek?: moment$CalendarFormat, - sameElse?: moment$CalendarFormat -}; - -declare class moment$LocaleData { - months(moment: moment$Moment): string, - monthsShort(moment: moment$Moment): string, - monthsParse(month: string): number, - weekdays(moment: moment$Moment): string, - weekdaysShort(moment: moment$Moment): string, - weekdaysMin(moment: moment$Moment): string, - weekdaysParse(weekDay: string): number, - longDateFormat(dateFormat: string): string, - isPM(date: string): boolean, - meridiem(hours: number, minutes: number, isLower: boolean): string, - calendar( - key: - | "sameDay" - | "nextDay" - | "lastDay" - | "nextWeek" - | "prevWeek" - | "sameElse", - moment: moment$Moment - ): string, - relativeTime( - number: number, - withoutSuffix: boolean, - key: "s" | "m" | "mm" | "h" | "hh" | "d" | "dd" | "M" | "MM" | "y" | "yy", - isFuture: boolean - ): string, - pastFuture(diff: any, relTime: string): string, - ordinal(number: number): string, - preparse(str: string): any, - postformat(str: string): any, - week(moment: moment$Moment): string, - invalidDate(): string, - firstDayOfWeek(): number, - firstDayOfYear(): number -} -declare class moment$MomentDuration { - humanize(suffix?: boolean): string, - milliseconds(): number, - asMilliseconds(): number, - seconds(): number, - asSeconds(): number, - minutes(): number, - asMinutes(): number, - hours(): number, - asHours(): number, - days(): number, - asDays(): number, - months(): number, - asWeeks(): number, - weeks(): number, - asMonths(): number, - years(): number, - asYears(): number, - add(value: number | moment$MomentDuration | Object, unit?: string): this, - subtract(value: number | moment$MomentDuration | Object, unit?: string): this, - as(unit: string): number, - get(unit: string): number, - toJSON(): string, - toISOString(): string, - isValid(): boolean -} -declare class moment$Moment { - static ISO_8601: string, - static ( - string?: string, - format?: string | Array, - strict?: boolean - ): moment$Moment, - static ( - string?: string, - format?: string | Array, - locale?: string, - strict?: boolean - ): moment$Moment, - static ( - initDate: ?Object | number | Date | Array | moment$Moment | string - ): moment$Moment, - static unix(seconds: number): moment$Moment, - static utc(): moment$Moment, - static utc(number: number | Array): moment$Moment, - static utc( - str: string, - str2?: string | Array, - str3?: string - ): moment$Moment, - static utc(moment: moment$Moment): moment$Moment, - static utc(date: Date): moment$Moment, - static parseZone(): moment$Moment, - static parseZone(rawDate: string): moment$Moment, - static parseZone( - rawDate: string, - format: string | Array - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - strict: boolean - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - locale: string, - strict: boolean - ): moment$Moment, - isValid(): boolean, - invalidAt(): 0 | 1 | 2 | 3 | 4 | 5 | 6, - creationData(): moment$MomentCreationData, - millisecond(number: number): this, - milliseconds(number: number): this, - millisecond(): number, - milliseconds(): number, - second(number: number): this, - seconds(number: number): this, - second(): number, - seconds(): number, - minute(number: number): this, - minutes(number: number): this, - minute(): number, - minutes(): number, - hour(number: number): this, - hours(number: number): this, - hour(): number, - hours(): number, - date(number: number): this, - dates(number: number): this, - date(): number, - dates(): number, - day(day: number | string): this, - days(day: number | string): this, - day(): number, - days(): number, - weekday(number: number): this, - weekday(): number, - isoWeekday(number: number): this, - isoWeekday(): number, - dayOfYear(number: number): this, - dayOfYear(): number, - week(number: number): this, - weeks(number: number): this, - week(): number, - weeks(): number, - isoWeek(number: number): this, - isoWeeks(number: number): this, - isoWeek(): number, - isoWeeks(): number, - month(number: number): this, - months(number: number): this, - month(): number, - months(): number, - quarter(number: number): this, - quarter(): number, - year(number: number): this, - years(number: number): this, - year(): number, - years(): number, - weekYear(number: number): this, - weekYear(): number, - isoWeekYear(number: number): this, - isoWeekYear(): number, - weeksInYear(): number, - isoWeeksInYear(): number, - get(string: string): number, - set(unit: string, value: number): this, - set(options: { [unit: string]: number }): this, - static max(...dates: Array): moment$Moment, - static max(dates: Array): moment$Moment, - static min(...dates: Array): moment$Moment, - static min(dates: Array): moment$Moment, - add( - value: number | moment$MomentDuration | moment$Moment | Object, - unit?: string - ): this, - subtract( - value: number | moment$MomentDuration | moment$Moment | string | Object, - unit?: string - ): this, - startOf(unit: string): this, - endOf(unit: string): this, - local(): this, - utc(): this, - utcOffset( - offset: number | string, - keepLocalTime?: boolean, - keepMinutes?: boolean - ): this, - utcOffset(): number, - format(format?: string): string, - fromNow(removeSuffix?: boolean): string, - from( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - toNow(removePrefix?: boolean): string, - to( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - calendar(refTime?: any, formats?: moment$CalendarFormats): string, - diff( - date: moment$Moment | string | number | Date | Array, - format?: string, - floating?: boolean - ): number, - valueOf(): number, - unix(): number, - daysInMonth(): number, - toDate(): Date, - toArray(): Array, - toJSON(): string, - toISOString( - keepOffset?: boolean - ): string, - toObject(): moment$MomentObject, - isBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSame( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isBetween( - fromDate: moment$Moment | string | number | Date | Array, - toDate?: ?moment$Moment | string | number | Date | Array, - granularity?: ?string, - inclusion?: ?string - ): boolean, - isDST(): boolean, - isDSTShifted(): boolean, - isLeapYear(): boolean, - clone(): moment$Moment, - static isMoment(obj: any): boolean, - static isDate(obj: any): boolean, - static locale(locale: string, localeData?: Object): string, - static updateLocale(locale: string, localeData?: ?Object): void, - static locale(locales: Array): string, - locale(locale: string, customization?: Object | null): moment$Moment, - locale(): string, - static months(): Array, - static monthsShort(): Array, - static weekdays(): Array, - static weekdaysShort(): Array, - static weekdaysMin(): Array, - static months(): string, - static monthsShort(): string, - static weekdays(): string, - static weekdaysShort(): string, - static weekdaysMin(): string, - static localeData(key?: string): moment$LocaleData, - static duration( - value: number | Object | string, - unit?: string - ): moment$MomentDuration, - static isDuration(obj: any): boolean, - static normalizeUnits(unit: string): string, - static invalid(object: any): moment$Moment -} - -declare module "moment" { - declare module.exports: Class; -} diff --git a/scm-plugins/scm-git-plugin/flow-typed/npm/react-jss_vx.x.x.js b/scm-plugins/scm-git-plugin/flow-typed/npm/react-jss_vx.x.x.js deleted file mode 100644 index cf8abae155..0000000000 --- a/scm-plugins/scm-git-plugin/flow-typed/npm/react-jss_vx.x.x.js +++ /dev/null @@ -1,137 +0,0 @@ -// flow-typed signature: ba35d02d668b0d0a3e04a63a6847974e -// flow-typed version: <>/react-jss_v8.6.1/flow_v0.79.1 - -/** - * This is an autogenerated libdef stub for: - * - * 'react-jss' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'react-jss' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'react-jss/dist/react-jss' { - declare module.exports: any; -} - -declare module 'react-jss/dist/react-jss.min' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/contextTypes' { - declare module.exports: any; -} - -declare module 'react-jss/lib/createHoc' { - declare module.exports: any; -} - -declare module 'react-jss/lib/getDisplayName' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/jss' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/ns' { - declare module.exports: any; -} - -declare module 'react-jss/lib/propTypes' { - declare module.exports: any; -} - -// Filename aliases -declare module 'react-jss/dist/react-jss.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss'>; -} -declare module 'react-jss/dist/react-jss.min.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss.min'>; -} -declare module 'react-jss/lib/compose.js' { - declare module.exports: $Exports<'react-jss/lib/compose'>; -} -declare module 'react-jss/lib/compose.test.js' { - declare module.exports: $Exports<'react-jss/lib/compose.test'>; -} -declare module 'react-jss/lib/contextTypes.js' { - declare module.exports: $Exports<'react-jss/lib/contextTypes'>; -} -declare module 'react-jss/lib/createHoc.js' { - declare module.exports: $Exports<'react-jss/lib/createHoc'>; -} -declare module 'react-jss/lib/getDisplayName.js' { - declare module.exports: $Exports<'react-jss/lib/getDisplayName'>; -} -declare module 'react-jss/lib/index.js' { - declare module.exports: $Exports<'react-jss/lib/index'>; -} -declare module 'react-jss/lib/index.test.js' { - declare module.exports: $Exports<'react-jss/lib/index.test'>; -} -declare module 'react-jss/lib/injectSheet.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet'>; -} -declare module 'react-jss/lib/injectSheet.test.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet.test'>; -} -declare module 'react-jss/lib/jss.js' { - declare module.exports: $Exports<'react-jss/lib/jss'>; -} -declare module 'react-jss/lib/JssProvider.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider'>; -} -declare module 'react-jss/lib/JssProvider.test.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider.test'>; -} -declare module 'react-jss/lib/ns.js' { - declare module.exports: $Exports<'react-jss/lib/ns'>; -} -declare module 'react-jss/lib/propTypes.js' { - declare module.exports: $Exports<'react-jss/lib/propTypes'>; -} diff --git a/scm-plugins/scm-git-plugin/package.json b/scm-plugins/scm-git-plugin/package.json index 8f0ab90d34..602d6d2ff0 100644 --- a/scm-plugins/scm-git-plugin/package.json +++ b/scm-plugins/scm-git-plugin/package.json @@ -3,12 +3,15 @@ "license" : "BSD-3-Clause", "main": "src/main/js/index.js", "scripts": { - "build": "ui-bundler plugin" + "build": "ui-bundler plugin", + "watch": "ui-bundler plugin -w", + "lint": "ui-bundler lint", + "flow": "flow check" }, "dependencies": { "@scm-manager/ui-extensions": "^0.0.7" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17" + "@scm-manager/ui-bundler": "^0.0.19" } } diff --git a/scm-plugins/scm-git-plugin/pom.xml b/scm-plugins/scm-git-plugin/pom.xml index 11e2a40bd0..bf8769daca 100644 --- a/scm-plugins/scm-git-plugin/pom.xml +++ b/scm-plugins/scm-git-plugin/pom.xml @@ -43,11 +43,20 @@ - - + + sonia.scm.maven + smp-maven-plugin + true + + true + + + + + org.apache.maven.plugins maven-jar-plugin @@ -61,33 +70,6 @@ - - com.github.sdorra - buildfrontend-maven-plugin - - - link-ui-types - process-sources - - install-link - - - @scm-manager/ui-types - - - - link-ui-components - process-sources - - install-link - - - @scm-manager/ui-components - - - - - diff --git a/scm-plugins/scm-git-plugin/yarn.lock b/scm-plugins/scm-git-plugin/yarn.lock index c1abfd6640..b85f672a8e 100644 --- a/scm-plugins/scm-git-plugin/yarn.lock +++ b/scm-plugins/scm-git-plugin/yarn.lock @@ -707,9 +707,9 @@ version "0.0.2" resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" diff --git a/scm-plugins/scm-hg-plugin/.flowconfig b/scm-plugins/scm-hg-plugin/.flowconfig index 7ede008602..b05e157358 100644 --- a/scm-plugins/scm-hg-plugin/.flowconfig +++ b/scm-plugins/scm-hg-plugin/.flowconfig @@ -4,5 +4,6 @@ [include] [libs] +./node_modules/@scm-manager/ui-components/flow-typed [options] diff --git a/scm-plugins/scm-hg-plugin/flow-typed/npm/classnames_v2.x.x.js b/scm-plugins/scm-hg-plugin/flow-typed/npm/classnames_v2.x.x.js deleted file mode 100644 index 2307243eeb..0000000000 --- a/scm-plugins/scm-hg-plugin/flow-typed/npm/classnames_v2.x.x.js +++ /dev/null @@ -1,23 +0,0 @@ -// flow-typed signature: cf86673cc32d185bdab1d2ea90578d37 -// flow-typed version: 614bf49aa8/classnames_v2.x.x/flow_>=v0.25.x - -type $npm$classnames$Classes = - | string - | { [className: string]: * } - | false - | void - | null; - -declare module "classnames" { - declare module.exports: ( - ...classes: Array<$npm$classnames$Classes | $npm$classnames$Classes[]> - ) => string; -} - -declare module "classnames/bind" { - declare module.exports: $Exports<"classnames">; -} - -declare module "classnames/dedupe" { - declare module.exports: $Exports<"classnames">; -} diff --git a/scm-plugins/scm-hg-plugin/flow-typed/npm/jest_v23.x.x.js b/scm-plugins/scm-hg-plugin/flow-typed/npm/jest_v23.x.x.js deleted file mode 100644 index 23b66b07e5..0000000000 --- a/scm-plugins/scm-hg-plugin/flow-typed/npm/jest_v23.x.x.js +++ /dev/null @@ -1,1108 +0,0 @@ -// flow-typed signature: f5a484315a3dea13d273645306e4076a -// flow-typed version: 7c5d14b3d4/jest_v23.x.x/flow_>=v0.39.x - -type JestMockFn, TReturn> = { - (...args: TArguments): TReturn, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: Array - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): void, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): void, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): void, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a string to use in test result output in place of "jest.fn()" to - * indicate which mock function is being referenced. - */ - mockName(name: string): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Accepts a value that will be returned whenever the mock function is called. - */ - mockReturnValue(value: TReturn): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: TReturn): JestMockFn, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) - */ - mockResolvedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) - */ - mockResolvedValueOnce(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) - */ - mockRejectedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) - */ - mockRejectedValueOnce(value: TReturn): JestMockFn> -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -/** - * Jest allows functions and classes to be used as test names in test() and - * describe() - */ -type JestTestName = string | Function; - -/** - * Plugin: jest-styled-components - */ - -type JestStyledComponentsMatcherValue = - | string - | JestAsymmetricEqualityType - | RegExp - | typeof undefined; - -type JestStyledComponentsMatcherOptions = { - media?: string; - modifier?: string; - supports?: string; -} - -type JestStyledComponentsMatchersType = { - toHaveStyleRule( - property: string, - value: JestStyledComponentsMatcherValue, - options?: JestStyledComponentsMatcherOptions - ): void, -}; - -/** - * Plugin: jest-enzyme - */ -type EnzymeMatchersType = { - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeEmptyRender(): void, - toBePresent(): void, - toContainReact(element: React$Element): void, - toExist(): void, - toHaveClassName(className: string): void, - toHaveHTML(html: string): void, - toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), - toHaveRef(refName: string): void, - toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), - toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), - toHaveTagName(tagName: string): void, - toHaveText(text: string): void, - toIncludeText(text: string): void, - toHaveValue(value: any): void, - toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void -}; - -// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers -type DomTestingLibraryType = { - toBeInTheDOM(): void, - toHaveTextContent(content: string): void, - toHaveAttribute(name: string, expectedValue?: string): void -}; - -// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers -type JestJQueryMatchersType = { - toExist(): void, - toHaveLength(len: number): void, - toHaveId(id: string): void, - toHaveClass(className: string): void, - toHaveTag(tag: string): void, - toHaveAttr(key: string, val?: any): void, - toHaveProp(key: string, val?: any): void, - toHaveText(text: string | RegExp): void, - toHaveData(key: string, val?: any): void, - toHaveValue(val: any): void, - toHaveCss(css: {[key: string]: any}): void, - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeHidden(): void, - toBeSelected(): void, - toBeVisible(): void, - toBeFocused(): void, - toBeInDom(): void, - toBeMatchedBy(sel: string): void, - toHaveDescendant(sel: string): void, - toHaveDescendantWithText(sel: string, text: string | RegExp): void -}; - - -// Jest Extended Matchers: https://github.com/jest-community/jest-extended -type JestExtendedMatchersType = { - /** - * Note: Currently unimplemented - * Passing assertion - * - * @param {String} message - */ - // pass(message: string): void; - - /** - * Note: Currently unimplemented - * Failing assertion - * - * @param {String} message - */ - // fail(message: string): void; - - /** - * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. - */ - toBeEmpty(): void; - - /** - * Use .toBeOneOf when checking if a value is a member of a given Array. - * @param {Array.<*>} members - */ - toBeOneOf(members: any[]): void; - - /** - * Use `.toBeNil` when checking a value is `null` or `undefined`. - */ - toBeNil(): void; - - /** - * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. - * @param {Function} predicate - */ - toSatisfy(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeArray` when checking if a value is an `Array`. - */ - toBeArray(): void; - - /** - * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. - * @param {Number} x - */ - toBeArrayOfSize(x: number): void; - - /** - * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. - * @param {Array.<*>} members - */ - toIncludeAllMembers(members: any[]): void; - - /** - * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. - * @param {Array.<*>} members - */ - toIncludeAnyMembers(members: any[]): void; - - /** - * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. - * @param {Function} predicate - */ - toSatisfyAll(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeBoolean` when checking if a value is a `Boolean`. - */ - toBeBoolean(): void; - - /** - * Use `.toBeTrue` when checking a value is equal (===) to `true`. - */ - toBeTrue(): void; - - /** - * Use `.toBeFalse` when checking a value is equal (===) to `false`. - */ - toBeFalse(): void; - - /** - * Use .toBeDate when checking if a value is a Date. - */ - toBeDate(): void; - - /** - * Use `.toBeFunction` when checking if a value is a `Function`. - */ - toBeFunction(): void; - - /** - * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. - * - * Note: Required Jest version >22 - * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same - * - * @param {Mock} mock - */ - toHaveBeenCalledBefore(mock: JestMockFn): void; - - /** - * Use `.toBeNumber` when checking if a value is a `Number`. - */ - toBeNumber(): void; - - /** - * Use `.toBeNaN` when checking a value is `NaN`. - */ - toBeNaN(): void; - - /** - * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. - */ - toBeFinite(): void; - - /** - * Use `.toBePositive` when checking if a value is a positive `Number`. - */ - toBePositive(): void; - - /** - * Use `.toBeNegative` when checking if a value is a negative `Number`. - */ - toBeNegative(): void; - - /** - * Use `.toBeEven` when checking if a value is an even `Number`. - */ - toBeEven(): void; - - /** - * Use `.toBeOdd` when checking if a value is an odd `Number`. - */ - toBeOdd(): void; - - /** - * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). - * - * @param {Number} start - * @param {Number} end - */ - toBeWithin(start: number, end: number): void; - - /** - * Use `.toBeObject` when checking if a value is an `Object`. - */ - toBeObject(): void; - - /** - * Use `.toContainKey` when checking if an object contains the provided key. - * - * @param {String} key - */ - toContainKey(key: string): void; - - /** - * Use `.toContainKeys` when checking if an object has all of the provided keys. - * - * @param {Array.} keys - */ - toContainKeys(keys: string[]): void; - - /** - * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. - * - * @param {Array.} keys - */ - toContainAllKeys(keys: string[]): void; - - /** - * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. - * - * @param {Array.} keys - */ - toContainAnyKeys(keys: string[]): void; - - /** - * Use `.toContainValue` when checking if an object contains the provided value. - * - * @param {*} value - */ - toContainValue(value: any): void; - - /** - * Use `.toContainValues` when checking if an object contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainValues(values: any[]): void; - - /** - * Use `.toContainAllValues` when checking if an object only contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainAllValues(values: any[]): void; - - /** - * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. - * - * @param {Array.<*>} values - */ - toContainAnyValues(values: any[]): void; - - /** - * Use `.toContainEntry` when checking if an object contains the provided entry. - * - * @param {Array.} entry - */ - toContainEntry(entry: [string, string]): void; - - /** - * Use `.toContainEntries` when checking if an object contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainAllEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. - * - * @param {Array.>} entries - */ - toContainAnyEntries(entries: [string, string][]): void; - - /** - * Use `.toBeExtensible` when checking if an object is extensible. - */ - toBeExtensible(): void; - - /** - * Use `.toBeFrozen` when checking if an object is frozen. - */ - toBeFrozen(): void; - - /** - * Use `.toBeSealed` when checking if an object is sealed. - */ - toBeSealed(): void; - - /** - * Use `.toBeString` when checking if a value is a `String`. - */ - toBeString(): void; - - /** - * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. - * - * @param {String} string - */ - toEqualCaseInsensitive(string: string): void; - - /** - * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. - * - * @param {String} prefix - */ - toStartWith(prefix: string): void; - - /** - * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. - * - * @param {String} suffix - */ - toEndWith(suffix: string): void; - - /** - * Use `.toInclude` when checking if a `String` includes the given `String` substring. - * - * @param {String} substring - */ - toInclude(substring: string): void; - - /** - * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. - * - * @param {String} substring - * @param {Number} times - */ - toIncludeRepeated(substring: string, times: number): void; - - /** - * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. - * - * @param {Array.} substring - */ - toIncludeMultiple(substring: string[]): void; -}; - -interface JestExpectType { - not: - & JestExpectType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - toBeCalled(): void; - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - toBeCalledTimes(number: number): void; - /** - * - */ - toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; - nthCalledWith(nthCall: number, ...args: Array): void; - /** - * - */ - toHaveReturned(): void; - toReturn(): void; - /** - * - */ - toHaveReturnedTimes(number: number): void; - toReturnTimes(number: number): void; - /** - * - */ - toHaveReturnedWith(value: any): void; - toReturnWith(value: any): void; - /** - * - */ - toHaveLastReturnedWith(value: any): void; - lastReturnedWith(value: any): void; - /** - * - */ - toHaveNthReturnedWith(nthCall: number, value: any): void; - nthReturnedWith(nthCall: number, value: any): void; - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - toBeCalledWith(...args: Array): void, - /** - * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called - * with specific arguments. - */ - toHaveBeenLastCalledWith(...args: Array): void, - lastCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression or string. - */ - toMatch(regexpOrString: RegExp | string): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object | Array): void, - /** - * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. - */ - toStrictEqual(value: any): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(name: string): void, - - toMatchInlineSnapshot(snapshot?: string): void, - toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void, - toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, -} - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Restores all mocks back to their original value. - */ - restoreAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn, TReturn>( - implementation?: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Returns the actual module instead of a mock, bypassing all checks on - * whether the module should receive a mock implementation or not. - */ - requireActual(moduleName: string): any, - /** - * Returns a mock module instead of the actual module, bypassing all checks - * on whether the module should be required normally or not. - */ - requireMock(moduleName: string): any, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - advanceTimersByTime(msToRun: number): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - * - * Renamed to `advanceTimersByTime`. - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, - /** - * Set the default timeout interval for tests and before/after hooks in milliseconds. - * Note: The default timeout interval is 5 seconds if this method is not called. - */ - setTimeout(timeout: number): JestObjectType -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before every test inside this context */ -declare function beforeEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; - -/** A context for grouping tests together */ -declare var describe: { - /** - * Creates a block that groups together several related tests in one "test suite" - */ - (name: JestTestName, fn: () => void): void, - - /** - * Only run this describe block - */ - only(name: JestTestName, fn: () => void): void, - - /** - * Skip running this describe block - */ - skip(name: JestTestName, fn: () => void): void -}; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - ( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - /** - * Only run this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - only( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): { - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - }, - /** - * Skip running this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - skip( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Run the test concurrently - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - concurrent( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void -}; -declare function fit( - name: JestTestName, - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -type JestPrettyFormatColors = { - comment: { close: string, open: string }, - content: { close: string, open: string }, - prop: { close: string, open: string }, - tag: { close: string, open: string }, - value: { close: string, open: string }, -}; - -type JestPrettyFormatIndent = string => string; -type JestPrettyFormatRefs = Array; -type JestPrettyFormatPrint = any => string; -type JestPrettyFormatStringOrNull = string | null; - -type JestPrettyFormatOptions = {| - callToJSON: boolean, - edgeSpacing: string, - escapeRegex: boolean, - highlight: boolean, - indent: number, - maxDepth: number, - min: boolean, - plugins: JestPrettyFormatPlugins, - printFunctionName: boolean, - spacing: string, - theme: {| - comment: string, - content: string, - prop: string, - tag: string, - value: string, - |}, -|}; - -type JestPrettyFormatPlugin = { - print: ( - val: any, - serialize: JestPrettyFormatPrint, - indent: JestPrettyFormatIndent, - opts: JestPrettyFormatOptions, - colors: JestPrettyFormatColors, - ) => string, - test: any => boolean, -}; - -type JestPrettyFormatPlugins = Array; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): - & JestExpectType - & JestPromiseType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - objectContaining(value: Object): Object, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): string, - stringMatching(value: string | RegExp): string, - not: { - arrayContaining: (value: $ReadOnlyArray) => Array, - objectContaining: (value: {}) => Object, - stringContaining: (value: string) => string, - stringMatching: (value: string | RegExp) => string, - }, -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jasmine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): Object, - stringMatching(value: string): string -}; diff --git a/scm-plugins/scm-hg-plugin/flow-typed/npm/moment_v2.3.x.js b/scm-plugins/scm-hg-plugin/flow-typed/npm/moment_v2.3.x.js deleted file mode 100644 index c2786e87fd..0000000000 --- a/scm-plugins/scm-hg-plugin/flow-typed/npm/moment_v2.3.x.js +++ /dev/null @@ -1,331 +0,0 @@ -// flow-typed signature: 23b805356f90ad9384dd88489654e380 -// flow-typed version: e9374c5fe9/moment_v2.3.x/flow_>=v0.25.x - -type moment$MomentOptions = { - y?: number | string, - year?: number | string, - years?: number | string, - M?: number | string, - month?: number | string, - months?: number | string, - d?: number | string, - day?: number | string, - days?: number | string, - date?: number | string, - h?: number | string, - hour?: number | string, - hours?: number | string, - m?: number | string, - minute?: number | string, - minutes?: number | string, - s?: number | string, - second?: number | string, - seconds?: number | string, - ms?: number | string, - millisecond?: number | string, - milliseconds?: number | string -}; - -type moment$MomentObject = { - years: number, - months: number, - date: number, - hours: number, - minutes: number, - seconds: number, - milliseconds: number -}; - -type moment$MomentCreationData = { - input: string, - format: string, - locale: Object, - isUTC: boolean, - strict: boolean -}; - -type moment$CalendarFormat = string | ((moment: moment$Moment) => string); - -type moment$CalendarFormats = { - sameDay?: moment$CalendarFormat, - nextDay?: moment$CalendarFormat, - nextWeek?: moment$CalendarFormat, - lastDay?: moment$CalendarFormat, - lastWeek?: moment$CalendarFormat, - sameElse?: moment$CalendarFormat -}; - -declare class moment$LocaleData { - months(moment: moment$Moment): string, - monthsShort(moment: moment$Moment): string, - monthsParse(month: string): number, - weekdays(moment: moment$Moment): string, - weekdaysShort(moment: moment$Moment): string, - weekdaysMin(moment: moment$Moment): string, - weekdaysParse(weekDay: string): number, - longDateFormat(dateFormat: string): string, - isPM(date: string): boolean, - meridiem(hours: number, minutes: number, isLower: boolean): string, - calendar( - key: - | "sameDay" - | "nextDay" - | "lastDay" - | "nextWeek" - | "prevWeek" - | "sameElse", - moment: moment$Moment - ): string, - relativeTime( - number: number, - withoutSuffix: boolean, - key: "s" | "m" | "mm" | "h" | "hh" | "d" | "dd" | "M" | "MM" | "y" | "yy", - isFuture: boolean - ): string, - pastFuture(diff: any, relTime: string): string, - ordinal(number: number): string, - preparse(str: string): any, - postformat(str: string): any, - week(moment: moment$Moment): string, - invalidDate(): string, - firstDayOfWeek(): number, - firstDayOfYear(): number -} -declare class moment$MomentDuration { - humanize(suffix?: boolean): string, - milliseconds(): number, - asMilliseconds(): number, - seconds(): number, - asSeconds(): number, - minutes(): number, - asMinutes(): number, - hours(): number, - asHours(): number, - days(): number, - asDays(): number, - months(): number, - asWeeks(): number, - weeks(): number, - asMonths(): number, - years(): number, - asYears(): number, - add(value: number | moment$MomentDuration | Object, unit?: string): this, - subtract(value: number | moment$MomentDuration | Object, unit?: string): this, - as(unit: string): number, - get(unit: string): number, - toJSON(): string, - toISOString(): string, - isValid(): boolean -} -declare class moment$Moment { - static ISO_8601: string, - static ( - string?: string, - format?: string | Array, - strict?: boolean - ): moment$Moment, - static ( - string?: string, - format?: string | Array, - locale?: string, - strict?: boolean - ): moment$Moment, - static ( - initDate: ?Object | number | Date | Array | moment$Moment | string - ): moment$Moment, - static unix(seconds: number): moment$Moment, - static utc(): moment$Moment, - static utc(number: number | Array): moment$Moment, - static utc( - str: string, - str2?: string | Array, - str3?: string - ): moment$Moment, - static utc(moment: moment$Moment): moment$Moment, - static utc(date: Date): moment$Moment, - static parseZone(): moment$Moment, - static parseZone(rawDate: string): moment$Moment, - static parseZone( - rawDate: string, - format: string | Array - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - strict: boolean - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - locale: string, - strict: boolean - ): moment$Moment, - isValid(): boolean, - invalidAt(): 0 | 1 | 2 | 3 | 4 | 5 | 6, - creationData(): moment$MomentCreationData, - millisecond(number: number): this, - milliseconds(number: number): this, - millisecond(): number, - milliseconds(): number, - second(number: number): this, - seconds(number: number): this, - second(): number, - seconds(): number, - minute(number: number): this, - minutes(number: number): this, - minute(): number, - minutes(): number, - hour(number: number): this, - hours(number: number): this, - hour(): number, - hours(): number, - date(number: number): this, - dates(number: number): this, - date(): number, - dates(): number, - day(day: number | string): this, - days(day: number | string): this, - day(): number, - days(): number, - weekday(number: number): this, - weekday(): number, - isoWeekday(number: number): this, - isoWeekday(): number, - dayOfYear(number: number): this, - dayOfYear(): number, - week(number: number): this, - weeks(number: number): this, - week(): number, - weeks(): number, - isoWeek(number: number): this, - isoWeeks(number: number): this, - isoWeek(): number, - isoWeeks(): number, - month(number: number): this, - months(number: number): this, - month(): number, - months(): number, - quarter(number: number): this, - quarter(): number, - year(number: number): this, - years(number: number): this, - year(): number, - years(): number, - weekYear(number: number): this, - weekYear(): number, - isoWeekYear(number: number): this, - isoWeekYear(): number, - weeksInYear(): number, - isoWeeksInYear(): number, - get(string: string): number, - set(unit: string, value: number): this, - set(options: { [unit: string]: number }): this, - static max(...dates: Array): moment$Moment, - static max(dates: Array): moment$Moment, - static min(...dates: Array): moment$Moment, - static min(dates: Array): moment$Moment, - add( - value: number | moment$MomentDuration | moment$Moment | Object, - unit?: string - ): this, - subtract( - value: number | moment$MomentDuration | moment$Moment | string | Object, - unit?: string - ): this, - startOf(unit: string): this, - endOf(unit: string): this, - local(): this, - utc(): this, - utcOffset( - offset: number | string, - keepLocalTime?: boolean, - keepMinutes?: boolean - ): this, - utcOffset(): number, - format(format?: string): string, - fromNow(removeSuffix?: boolean): string, - from( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - toNow(removePrefix?: boolean): string, - to( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - calendar(refTime?: any, formats?: moment$CalendarFormats): string, - diff( - date: moment$Moment | string | number | Date | Array, - format?: string, - floating?: boolean - ): number, - valueOf(): number, - unix(): number, - daysInMonth(): number, - toDate(): Date, - toArray(): Array, - toJSON(): string, - toISOString( - keepOffset?: boolean - ): string, - toObject(): moment$MomentObject, - isBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSame( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isBetween( - fromDate: moment$Moment | string | number | Date | Array, - toDate?: ?moment$Moment | string | number | Date | Array, - granularity?: ?string, - inclusion?: ?string - ): boolean, - isDST(): boolean, - isDSTShifted(): boolean, - isLeapYear(): boolean, - clone(): moment$Moment, - static isMoment(obj: any): boolean, - static isDate(obj: any): boolean, - static locale(locale: string, localeData?: Object): string, - static updateLocale(locale: string, localeData?: ?Object): void, - static locale(locales: Array): string, - locale(locale: string, customization?: Object | null): moment$Moment, - locale(): string, - static months(): Array, - static monthsShort(): Array, - static weekdays(): Array, - static weekdaysShort(): Array, - static weekdaysMin(): Array, - static months(): string, - static monthsShort(): string, - static weekdays(): string, - static weekdaysShort(): string, - static weekdaysMin(): string, - static localeData(key?: string): moment$LocaleData, - static duration( - value: number | Object | string, - unit?: string - ): moment$MomentDuration, - static isDuration(obj: any): boolean, - static normalizeUnits(unit: string): string, - static invalid(object: any): moment$Moment -} - -declare module "moment" { - declare module.exports: Class; -} diff --git a/scm-plugins/scm-hg-plugin/flow-typed/npm/react-jss_vx.x.x.js b/scm-plugins/scm-hg-plugin/flow-typed/npm/react-jss_vx.x.x.js deleted file mode 100644 index cf8abae155..0000000000 --- a/scm-plugins/scm-hg-plugin/flow-typed/npm/react-jss_vx.x.x.js +++ /dev/null @@ -1,137 +0,0 @@ -// flow-typed signature: ba35d02d668b0d0a3e04a63a6847974e -// flow-typed version: <>/react-jss_v8.6.1/flow_v0.79.1 - -/** - * This is an autogenerated libdef stub for: - * - * 'react-jss' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'react-jss' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'react-jss/dist/react-jss' { - declare module.exports: any; -} - -declare module 'react-jss/dist/react-jss.min' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/contextTypes' { - declare module.exports: any; -} - -declare module 'react-jss/lib/createHoc' { - declare module.exports: any; -} - -declare module 'react-jss/lib/getDisplayName' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/jss' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/ns' { - declare module.exports: any; -} - -declare module 'react-jss/lib/propTypes' { - declare module.exports: any; -} - -// Filename aliases -declare module 'react-jss/dist/react-jss.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss'>; -} -declare module 'react-jss/dist/react-jss.min.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss.min'>; -} -declare module 'react-jss/lib/compose.js' { - declare module.exports: $Exports<'react-jss/lib/compose'>; -} -declare module 'react-jss/lib/compose.test.js' { - declare module.exports: $Exports<'react-jss/lib/compose.test'>; -} -declare module 'react-jss/lib/contextTypes.js' { - declare module.exports: $Exports<'react-jss/lib/contextTypes'>; -} -declare module 'react-jss/lib/createHoc.js' { - declare module.exports: $Exports<'react-jss/lib/createHoc'>; -} -declare module 'react-jss/lib/getDisplayName.js' { - declare module.exports: $Exports<'react-jss/lib/getDisplayName'>; -} -declare module 'react-jss/lib/index.js' { - declare module.exports: $Exports<'react-jss/lib/index'>; -} -declare module 'react-jss/lib/index.test.js' { - declare module.exports: $Exports<'react-jss/lib/index.test'>; -} -declare module 'react-jss/lib/injectSheet.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet'>; -} -declare module 'react-jss/lib/injectSheet.test.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet.test'>; -} -declare module 'react-jss/lib/jss.js' { - declare module.exports: $Exports<'react-jss/lib/jss'>; -} -declare module 'react-jss/lib/JssProvider.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider'>; -} -declare module 'react-jss/lib/JssProvider.test.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider.test'>; -} -declare module 'react-jss/lib/ns.js' { - declare module.exports: $Exports<'react-jss/lib/ns'>; -} -declare module 'react-jss/lib/propTypes.js' { - declare module.exports: $Exports<'react-jss/lib/propTypes'>; -} diff --git a/scm-plugins/scm-hg-plugin/package.json b/scm-plugins/scm-hg-plugin/package.json index a2ebd0e6ad..1398432412 100644 --- a/scm-plugins/scm-hg-plugin/package.json +++ b/scm-plugins/scm-hg-plugin/package.json @@ -9,6 +9,6 @@ "@scm-manager/ui-extensions": "^0.0.7" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17" + "@scm-manager/ui-bundler": "^0.0.19" } } diff --git a/scm-plugins/scm-hg-plugin/pom.xml b/scm-plugins/scm-hg-plugin/pom.xml index 3da97d09e8..8dcc653642 100644 --- a/scm-plugins/scm-hg-plugin/pom.xml +++ b/scm-plugins/scm-hg-plugin/pom.xml @@ -31,8 +31,6 @@ - - @@ -54,7 +52,18 @@ true - + + + sonia.scm.maven + smp-maven-plugin + true + + true + + + + + org.apache.maven.plugins maven-jar-plugin @@ -68,33 +77,6 @@ - - com.github.sdorra - buildfrontend-maven-plugin - - - link-ui-types - process-sources - - install-link - - - @scm-manager/ui-types - - - - link-ui-components - process-sources - - install-link - - - @scm-manager/ui-components - - - - - diff --git a/scm-plugins/scm-hg-plugin/yarn.lock b/scm-plugins/scm-hg-plugin/yarn.lock index c3e8cc476f..70d4169198 100644 --- a/scm-plugins/scm-hg-plugin/yarn.lock +++ b/scm-plugins/scm-hg-plugin/yarn.lock @@ -641,9 +641,9 @@ version "0.0.2" resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" @@ -660,6 +660,7 @@ browserify-css "^0.14.0" colors "^1.3.1" commander "^2.17.1" + connect-history-api-fallback "^1.5.0" eslint "^5.4.0" eslint-config-react-app "^2.1.0" eslint-plugin-flowtype "^2.50.0" diff --git a/scm-plugins/scm-legacy-plugin/pom.xml b/scm-plugins/scm-legacy-plugin/pom.xml index 31d8422fbf..52aff51dd2 100644 --- a/scm-plugins/scm-legacy-plugin/pom.xml +++ b/scm-plugins/scm-legacy-plugin/pom.xml @@ -23,4 +23,19 @@ - \ No newline at end of file + + + + + + sonia.scm.maven + smp-maven-plugin + true + + true + + + + + + diff --git a/scm-plugins/scm-svn-plugin/.flowconfig b/scm-plugins/scm-svn-plugin/.flowconfig index 7ede008602..b05e157358 100644 --- a/scm-plugins/scm-svn-plugin/.flowconfig +++ b/scm-plugins/scm-svn-plugin/.flowconfig @@ -4,5 +4,6 @@ [include] [libs] +./node_modules/@scm-manager/ui-components/flow-typed [options] diff --git a/scm-plugins/scm-svn-plugin/flow-typed/npm/classnames_v2.x.x.js b/scm-plugins/scm-svn-plugin/flow-typed/npm/classnames_v2.x.x.js deleted file mode 100644 index 2307243eeb..0000000000 --- a/scm-plugins/scm-svn-plugin/flow-typed/npm/classnames_v2.x.x.js +++ /dev/null @@ -1,23 +0,0 @@ -// flow-typed signature: cf86673cc32d185bdab1d2ea90578d37 -// flow-typed version: 614bf49aa8/classnames_v2.x.x/flow_>=v0.25.x - -type $npm$classnames$Classes = - | string - | { [className: string]: * } - | false - | void - | null; - -declare module "classnames" { - declare module.exports: ( - ...classes: Array<$npm$classnames$Classes | $npm$classnames$Classes[]> - ) => string; -} - -declare module "classnames/bind" { - declare module.exports: $Exports<"classnames">; -} - -declare module "classnames/dedupe" { - declare module.exports: $Exports<"classnames">; -} diff --git a/scm-plugins/scm-svn-plugin/flow-typed/npm/jest_v23.x.x.js b/scm-plugins/scm-svn-plugin/flow-typed/npm/jest_v23.x.x.js deleted file mode 100644 index 23b66b07e5..0000000000 --- a/scm-plugins/scm-svn-plugin/flow-typed/npm/jest_v23.x.x.js +++ /dev/null @@ -1,1108 +0,0 @@ -// flow-typed signature: f5a484315a3dea13d273645306e4076a -// flow-typed version: 7c5d14b3d4/jest_v23.x.x/flow_>=v0.39.x - -type JestMockFn, TReturn> = { - (...args: TArguments): TReturn, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: Array - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): void, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): void, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): void, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a string to use in test result output in place of "jest.fn()" to - * indicate which mock function is being referenced. - */ - mockName(name: string): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Accepts a value that will be returned whenever the mock function is called. - */ - mockReturnValue(value: TReturn): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: TReturn): JestMockFn, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) - */ - mockResolvedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) - */ - mockResolvedValueOnce(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) - */ - mockRejectedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) - */ - mockRejectedValueOnce(value: TReturn): JestMockFn> -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -/** - * Jest allows functions and classes to be used as test names in test() and - * describe() - */ -type JestTestName = string | Function; - -/** - * Plugin: jest-styled-components - */ - -type JestStyledComponentsMatcherValue = - | string - | JestAsymmetricEqualityType - | RegExp - | typeof undefined; - -type JestStyledComponentsMatcherOptions = { - media?: string; - modifier?: string; - supports?: string; -} - -type JestStyledComponentsMatchersType = { - toHaveStyleRule( - property: string, - value: JestStyledComponentsMatcherValue, - options?: JestStyledComponentsMatcherOptions - ): void, -}; - -/** - * Plugin: jest-enzyme - */ -type EnzymeMatchersType = { - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeEmptyRender(): void, - toBePresent(): void, - toContainReact(element: React$Element): void, - toExist(): void, - toHaveClassName(className: string): void, - toHaveHTML(html: string): void, - toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), - toHaveRef(refName: string): void, - toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), - toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), - toHaveTagName(tagName: string): void, - toHaveText(text: string): void, - toIncludeText(text: string): void, - toHaveValue(value: any): void, - toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void -}; - -// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers -type DomTestingLibraryType = { - toBeInTheDOM(): void, - toHaveTextContent(content: string): void, - toHaveAttribute(name: string, expectedValue?: string): void -}; - -// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers -type JestJQueryMatchersType = { - toExist(): void, - toHaveLength(len: number): void, - toHaveId(id: string): void, - toHaveClass(className: string): void, - toHaveTag(tag: string): void, - toHaveAttr(key: string, val?: any): void, - toHaveProp(key: string, val?: any): void, - toHaveText(text: string | RegExp): void, - toHaveData(key: string, val?: any): void, - toHaveValue(val: any): void, - toHaveCss(css: {[key: string]: any}): void, - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeHidden(): void, - toBeSelected(): void, - toBeVisible(): void, - toBeFocused(): void, - toBeInDom(): void, - toBeMatchedBy(sel: string): void, - toHaveDescendant(sel: string): void, - toHaveDescendantWithText(sel: string, text: string | RegExp): void -}; - - -// Jest Extended Matchers: https://github.com/jest-community/jest-extended -type JestExtendedMatchersType = { - /** - * Note: Currently unimplemented - * Passing assertion - * - * @param {String} message - */ - // pass(message: string): void; - - /** - * Note: Currently unimplemented - * Failing assertion - * - * @param {String} message - */ - // fail(message: string): void; - - /** - * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. - */ - toBeEmpty(): void; - - /** - * Use .toBeOneOf when checking if a value is a member of a given Array. - * @param {Array.<*>} members - */ - toBeOneOf(members: any[]): void; - - /** - * Use `.toBeNil` when checking a value is `null` or `undefined`. - */ - toBeNil(): void; - - /** - * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. - * @param {Function} predicate - */ - toSatisfy(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeArray` when checking if a value is an `Array`. - */ - toBeArray(): void; - - /** - * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. - * @param {Number} x - */ - toBeArrayOfSize(x: number): void; - - /** - * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. - * @param {Array.<*>} members - */ - toIncludeAllMembers(members: any[]): void; - - /** - * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. - * @param {Array.<*>} members - */ - toIncludeAnyMembers(members: any[]): void; - - /** - * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. - * @param {Function} predicate - */ - toSatisfyAll(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeBoolean` when checking if a value is a `Boolean`. - */ - toBeBoolean(): void; - - /** - * Use `.toBeTrue` when checking a value is equal (===) to `true`. - */ - toBeTrue(): void; - - /** - * Use `.toBeFalse` when checking a value is equal (===) to `false`. - */ - toBeFalse(): void; - - /** - * Use .toBeDate when checking if a value is a Date. - */ - toBeDate(): void; - - /** - * Use `.toBeFunction` when checking if a value is a `Function`. - */ - toBeFunction(): void; - - /** - * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. - * - * Note: Required Jest version >22 - * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same - * - * @param {Mock} mock - */ - toHaveBeenCalledBefore(mock: JestMockFn): void; - - /** - * Use `.toBeNumber` when checking if a value is a `Number`. - */ - toBeNumber(): void; - - /** - * Use `.toBeNaN` when checking a value is `NaN`. - */ - toBeNaN(): void; - - /** - * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. - */ - toBeFinite(): void; - - /** - * Use `.toBePositive` when checking if a value is a positive `Number`. - */ - toBePositive(): void; - - /** - * Use `.toBeNegative` when checking if a value is a negative `Number`. - */ - toBeNegative(): void; - - /** - * Use `.toBeEven` when checking if a value is an even `Number`. - */ - toBeEven(): void; - - /** - * Use `.toBeOdd` when checking if a value is an odd `Number`. - */ - toBeOdd(): void; - - /** - * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). - * - * @param {Number} start - * @param {Number} end - */ - toBeWithin(start: number, end: number): void; - - /** - * Use `.toBeObject` when checking if a value is an `Object`. - */ - toBeObject(): void; - - /** - * Use `.toContainKey` when checking if an object contains the provided key. - * - * @param {String} key - */ - toContainKey(key: string): void; - - /** - * Use `.toContainKeys` when checking if an object has all of the provided keys. - * - * @param {Array.} keys - */ - toContainKeys(keys: string[]): void; - - /** - * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. - * - * @param {Array.} keys - */ - toContainAllKeys(keys: string[]): void; - - /** - * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. - * - * @param {Array.} keys - */ - toContainAnyKeys(keys: string[]): void; - - /** - * Use `.toContainValue` when checking if an object contains the provided value. - * - * @param {*} value - */ - toContainValue(value: any): void; - - /** - * Use `.toContainValues` when checking if an object contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainValues(values: any[]): void; - - /** - * Use `.toContainAllValues` when checking if an object only contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainAllValues(values: any[]): void; - - /** - * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. - * - * @param {Array.<*>} values - */ - toContainAnyValues(values: any[]): void; - - /** - * Use `.toContainEntry` when checking if an object contains the provided entry. - * - * @param {Array.} entry - */ - toContainEntry(entry: [string, string]): void; - - /** - * Use `.toContainEntries` when checking if an object contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainAllEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. - * - * @param {Array.>} entries - */ - toContainAnyEntries(entries: [string, string][]): void; - - /** - * Use `.toBeExtensible` when checking if an object is extensible. - */ - toBeExtensible(): void; - - /** - * Use `.toBeFrozen` when checking if an object is frozen. - */ - toBeFrozen(): void; - - /** - * Use `.toBeSealed` when checking if an object is sealed. - */ - toBeSealed(): void; - - /** - * Use `.toBeString` when checking if a value is a `String`. - */ - toBeString(): void; - - /** - * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. - * - * @param {String} string - */ - toEqualCaseInsensitive(string: string): void; - - /** - * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. - * - * @param {String} prefix - */ - toStartWith(prefix: string): void; - - /** - * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. - * - * @param {String} suffix - */ - toEndWith(suffix: string): void; - - /** - * Use `.toInclude` when checking if a `String` includes the given `String` substring. - * - * @param {String} substring - */ - toInclude(substring: string): void; - - /** - * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. - * - * @param {String} substring - * @param {Number} times - */ - toIncludeRepeated(substring: string, times: number): void; - - /** - * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. - * - * @param {Array.} substring - */ - toIncludeMultiple(substring: string[]): void; -}; - -interface JestExpectType { - not: - & JestExpectType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - toBeCalled(): void; - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - toBeCalledTimes(number: number): void; - /** - * - */ - toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; - nthCalledWith(nthCall: number, ...args: Array): void; - /** - * - */ - toHaveReturned(): void; - toReturn(): void; - /** - * - */ - toHaveReturnedTimes(number: number): void; - toReturnTimes(number: number): void; - /** - * - */ - toHaveReturnedWith(value: any): void; - toReturnWith(value: any): void; - /** - * - */ - toHaveLastReturnedWith(value: any): void; - lastReturnedWith(value: any): void; - /** - * - */ - toHaveNthReturnedWith(nthCall: number, value: any): void; - nthReturnedWith(nthCall: number, value: any): void; - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - toBeCalledWith(...args: Array): void, - /** - * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called - * with specific arguments. - */ - toHaveBeenLastCalledWith(...args: Array): void, - lastCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression or string. - */ - toMatch(regexpOrString: RegExp | string): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object | Array): void, - /** - * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. - */ - toStrictEqual(value: any): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(name: string): void, - - toMatchInlineSnapshot(snapshot?: string): void, - toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void, - toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, -} - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Restores all mocks back to their original value. - */ - restoreAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn, TReturn>( - implementation?: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Returns the actual module instead of a mock, bypassing all checks on - * whether the module should receive a mock implementation or not. - */ - requireActual(moduleName: string): any, - /** - * Returns a mock module instead of the actual module, bypassing all checks - * on whether the module should be required normally or not. - */ - requireMock(moduleName: string): any, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - advanceTimersByTime(msToRun: number): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - * - * Renamed to `advanceTimersByTime`. - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, - /** - * Set the default timeout interval for tests and before/after hooks in milliseconds. - * Note: The default timeout interval is 5 seconds if this method is not called. - */ - setTimeout(timeout: number): JestObjectType -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before every test inside this context */ -declare function beforeEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; - -/** A context for grouping tests together */ -declare var describe: { - /** - * Creates a block that groups together several related tests in one "test suite" - */ - (name: JestTestName, fn: () => void): void, - - /** - * Only run this describe block - */ - only(name: JestTestName, fn: () => void): void, - - /** - * Skip running this describe block - */ - skip(name: JestTestName, fn: () => void): void -}; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - ( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - /** - * Only run this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - only( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): { - each( - table: Array> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - }, - /** - * Skip running this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - skip( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Run the test concurrently - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - concurrent( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void -}; -declare function fit( - name: JestTestName, - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -type JestPrettyFormatColors = { - comment: { close: string, open: string }, - content: { close: string, open: string }, - prop: { close: string, open: string }, - tag: { close: string, open: string }, - value: { close: string, open: string }, -}; - -type JestPrettyFormatIndent = string => string; -type JestPrettyFormatRefs = Array; -type JestPrettyFormatPrint = any => string; -type JestPrettyFormatStringOrNull = string | null; - -type JestPrettyFormatOptions = {| - callToJSON: boolean, - edgeSpacing: string, - escapeRegex: boolean, - highlight: boolean, - indent: number, - maxDepth: number, - min: boolean, - plugins: JestPrettyFormatPlugins, - printFunctionName: boolean, - spacing: string, - theme: {| - comment: string, - content: string, - prop: string, - tag: string, - value: string, - |}, -|}; - -type JestPrettyFormatPlugin = { - print: ( - val: any, - serialize: JestPrettyFormatPrint, - indent: JestPrettyFormatIndent, - opts: JestPrettyFormatOptions, - colors: JestPrettyFormatColors, - ) => string, - test: any => boolean, -}; - -type JestPrettyFormatPlugins = Array; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): - & JestExpectType - & JestPromiseType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - objectContaining(value: Object): Object, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): string, - stringMatching(value: string | RegExp): string, - not: { - arrayContaining: (value: $ReadOnlyArray) => Array, - objectContaining: (value: {}) => Object, - stringContaining: (value: string) => string, - stringMatching: (value: string | RegExp) => string, - }, -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jasmine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): Object, - stringMatching(value: string): string -}; diff --git a/scm-plugins/scm-svn-plugin/flow-typed/npm/moment_v2.3.x.js b/scm-plugins/scm-svn-plugin/flow-typed/npm/moment_v2.3.x.js deleted file mode 100644 index c2786e87fd..0000000000 --- a/scm-plugins/scm-svn-plugin/flow-typed/npm/moment_v2.3.x.js +++ /dev/null @@ -1,331 +0,0 @@ -// flow-typed signature: 23b805356f90ad9384dd88489654e380 -// flow-typed version: e9374c5fe9/moment_v2.3.x/flow_>=v0.25.x - -type moment$MomentOptions = { - y?: number | string, - year?: number | string, - years?: number | string, - M?: number | string, - month?: number | string, - months?: number | string, - d?: number | string, - day?: number | string, - days?: number | string, - date?: number | string, - h?: number | string, - hour?: number | string, - hours?: number | string, - m?: number | string, - minute?: number | string, - minutes?: number | string, - s?: number | string, - second?: number | string, - seconds?: number | string, - ms?: number | string, - millisecond?: number | string, - milliseconds?: number | string -}; - -type moment$MomentObject = { - years: number, - months: number, - date: number, - hours: number, - minutes: number, - seconds: number, - milliseconds: number -}; - -type moment$MomentCreationData = { - input: string, - format: string, - locale: Object, - isUTC: boolean, - strict: boolean -}; - -type moment$CalendarFormat = string | ((moment: moment$Moment) => string); - -type moment$CalendarFormats = { - sameDay?: moment$CalendarFormat, - nextDay?: moment$CalendarFormat, - nextWeek?: moment$CalendarFormat, - lastDay?: moment$CalendarFormat, - lastWeek?: moment$CalendarFormat, - sameElse?: moment$CalendarFormat -}; - -declare class moment$LocaleData { - months(moment: moment$Moment): string, - monthsShort(moment: moment$Moment): string, - monthsParse(month: string): number, - weekdays(moment: moment$Moment): string, - weekdaysShort(moment: moment$Moment): string, - weekdaysMin(moment: moment$Moment): string, - weekdaysParse(weekDay: string): number, - longDateFormat(dateFormat: string): string, - isPM(date: string): boolean, - meridiem(hours: number, minutes: number, isLower: boolean): string, - calendar( - key: - | "sameDay" - | "nextDay" - | "lastDay" - | "nextWeek" - | "prevWeek" - | "sameElse", - moment: moment$Moment - ): string, - relativeTime( - number: number, - withoutSuffix: boolean, - key: "s" | "m" | "mm" | "h" | "hh" | "d" | "dd" | "M" | "MM" | "y" | "yy", - isFuture: boolean - ): string, - pastFuture(diff: any, relTime: string): string, - ordinal(number: number): string, - preparse(str: string): any, - postformat(str: string): any, - week(moment: moment$Moment): string, - invalidDate(): string, - firstDayOfWeek(): number, - firstDayOfYear(): number -} -declare class moment$MomentDuration { - humanize(suffix?: boolean): string, - milliseconds(): number, - asMilliseconds(): number, - seconds(): number, - asSeconds(): number, - minutes(): number, - asMinutes(): number, - hours(): number, - asHours(): number, - days(): number, - asDays(): number, - months(): number, - asWeeks(): number, - weeks(): number, - asMonths(): number, - years(): number, - asYears(): number, - add(value: number | moment$MomentDuration | Object, unit?: string): this, - subtract(value: number | moment$MomentDuration | Object, unit?: string): this, - as(unit: string): number, - get(unit: string): number, - toJSON(): string, - toISOString(): string, - isValid(): boolean -} -declare class moment$Moment { - static ISO_8601: string, - static ( - string?: string, - format?: string | Array, - strict?: boolean - ): moment$Moment, - static ( - string?: string, - format?: string | Array, - locale?: string, - strict?: boolean - ): moment$Moment, - static ( - initDate: ?Object | number | Date | Array | moment$Moment | string - ): moment$Moment, - static unix(seconds: number): moment$Moment, - static utc(): moment$Moment, - static utc(number: number | Array): moment$Moment, - static utc( - str: string, - str2?: string | Array, - str3?: string - ): moment$Moment, - static utc(moment: moment$Moment): moment$Moment, - static utc(date: Date): moment$Moment, - static parseZone(): moment$Moment, - static parseZone(rawDate: string): moment$Moment, - static parseZone( - rawDate: string, - format: string | Array - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - strict: boolean - ): moment$Moment, - static parseZone( - rawDate: string, - format: string, - locale: string, - strict: boolean - ): moment$Moment, - isValid(): boolean, - invalidAt(): 0 | 1 | 2 | 3 | 4 | 5 | 6, - creationData(): moment$MomentCreationData, - millisecond(number: number): this, - milliseconds(number: number): this, - millisecond(): number, - milliseconds(): number, - second(number: number): this, - seconds(number: number): this, - second(): number, - seconds(): number, - minute(number: number): this, - minutes(number: number): this, - minute(): number, - minutes(): number, - hour(number: number): this, - hours(number: number): this, - hour(): number, - hours(): number, - date(number: number): this, - dates(number: number): this, - date(): number, - dates(): number, - day(day: number | string): this, - days(day: number | string): this, - day(): number, - days(): number, - weekday(number: number): this, - weekday(): number, - isoWeekday(number: number): this, - isoWeekday(): number, - dayOfYear(number: number): this, - dayOfYear(): number, - week(number: number): this, - weeks(number: number): this, - week(): number, - weeks(): number, - isoWeek(number: number): this, - isoWeeks(number: number): this, - isoWeek(): number, - isoWeeks(): number, - month(number: number): this, - months(number: number): this, - month(): number, - months(): number, - quarter(number: number): this, - quarter(): number, - year(number: number): this, - years(number: number): this, - year(): number, - years(): number, - weekYear(number: number): this, - weekYear(): number, - isoWeekYear(number: number): this, - isoWeekYear(): number, - weeksInYear(): number, - isoWeeksInYear(): number, - get(string: string): number, - set(unit: string, value: number): this, - set(options: { [unit: string]: number }): this, - static max(...dates: Array): moment$Moment, - static max(dates: Array): moment$Moment, - static min(...dates: Array): moment$Moment, - static min(dates: Array): moment$Moment, - add( - value: number | moment$MomentDuration | moment$Moment | Object, - unit?: string - ): this, - subtract( - value: number | moment$MomentDuration | moment$Moment | string | Object, - unit?: string - ): this, - startOf(unit: string): this, - endOf(unit: string): this, - local(): this, - utc(): this, - utcOffset( - offset: number | string, - keepLocalTime?: boolean, - keepMinutes?: boolean - ): this, - utcOffset(): number, - format(format?: string): string, - fromNow(removeSuffix?: boolean): string, - from( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - toNow(removePrefix?: boolean): string, - to( - value: moment$Moment | string | number | Date | Array, - removePrefix?: boolean - ): string, - calendar(refTime?: any, formats?: moment$CalendarFormats): string, - diff( - date: moment$Moment | string | number | Date | Array, - format?: string, - floating?: boolean - ): number, - valueOf(): number, - unix(): number, - daysInMonth(): number, - toDate(): Date, - toArray(): Array, - toJSON(): string, - toISOString( - keepOffset?: boolean - ): string, - toObject(): moment$MomentObject, - isBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSame( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrBefore( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isSameOrAfter( - date?: moment$Moment | string | number | Date | Array, - units?: ?string - ): boolean, - isBetween( - fromDate: moment$Moment | string | number | Date | Array, - toDate?: ?moment$Moment | string | number | Date | Array, - granularity?: ?string, - inclusion?: ?string - ): boolean, - isDST(): boolean, - isDSTShifted(): boolean, - isLeapYear(): boolean, - clone(): moment$Moment, - static isMoment(obj: any): boolean, - static isDate(obj: any): boolean, - static locale(locale: string, localeData?: Object): string, - static updateLocale(locale: string, localeData?: ?Object): void, - static locale(locales: Array): string, - locale(locale: string, customization?: Object | null): moment$Moment, - locale(): string, - static months(): Array, - static monthsShort(): Array, - static weekdays(): Array, - static weekdaysShort(): Array, - static weekdaysMin(): Array, - static months(): string, - static monthsShort(): string, - static weekdays(): string, - static weekdaysShort(): string, - static weekdaysMin(): string, - static localeData(key?: string): moment$LocaleData, - static duration( - value: number | Object | string, - unit?: string - ): moment$MomentDuration, - static isDuration(obj: any): boolean, - static normalizeUnits(unit: string): string, - static invalid(object: any): moment$Moment -} - -declare module "moment" { - declare module.exports: Class; -} diff --git a/scm-plugins/scm-svn-plugin/flow-typed/npm/react-jss_vx.x.x.js b/scm-plugins/scm-svn-plugin/flow-typed/npm/react-jss_vx.x.x.js deleted file mode 100644 index cf8abae155..0000000000 --- a/scm-plugins/scm-svn-plugin/flow-typed/npm/react-jss_vx.x.x.js +++ /dev/null @@ -1,137 +0,0 @@ -// flow-typed signature: ba35d02d668b0d0a3e04a63a6847974e -// flow-typed version: <>/react-jss_v8.6.1/flow_v0.79.1 - -/** - * This is an autogenerated libdef stub for: - * - * 'react-jss' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'react-jss' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'react-jss/dist/react-jss' { - declare module.exports: any; -} - -declare module 'react-jss/dist/react-jss.min' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose' { - declare module.exports: any; -} - -declare module 'react-jss/lib/compose.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/contextTypes' { - declare module.exports: any; -} - -declare module 'react-jss/lib/createHoc' { - declare module.exports: any; -} - -declare module 'react-jss/lib/getDisplayName' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index' { - declare module.exports: any; -} - -declare module 'react-jss/lib/index.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet' { - declare module.exports: any; -} - -declare module 'react-jss/lib/injectSheet.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/jss' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider' { - declare module.exports: any; -} - -declare module 'react-jss/lib/JssProvider.test' { - declare module.exports: any; -} - -declare module 'react-jss/lib/ns' { - declare module.exports: any; -} - -declare module 'react-jss/lib/propTypes' { - declare module.exports: any; -} - -// Filename aliases -declare module 'react-jss/dist/react-jss.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss'>; -} -declare module 'react-jss/dist/react-jss.min.js' { - declare module.exports: $Exports<'react-jss/dist/react-jss.min'>; -} -declare module 'react-jss/lib/compose.js' { - declare module.exports: $Exports<'react-jss/lib/compose'>; -} -declare module 'react-jss/lib/compose.test.js' { - declare module.exports: $Exports<'react-jss/lib/compose.test'>; -} -declare module 'react-jss/lib/contextTypes.js' { - declare module.exports: $Exports<'react-jss/lib/contextTypes'>; -} -declare module 'react-jss/lib/createHoc.js' { - declare module.exports: $Exports<'react-jss/lib/createHoc'>; -} -declare module 'react-jss/lib/getDisplayName.js' { - declare module.exports: $Exports<'react-jss/lib/getDisplayName'>; -} -declare module 'react-jss/lib/index.js' { - declare module.exports: $Exports<'react-jss/lib/index'>; -} -declare module 'react-jss/lib/index.test.js' { - declare module.exports: $Exports<'react-jss/lib/index.test'>; -} -declare module 'react-jss/lib/injectSheet.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet'>; -} -declare module 'react-jss/lib/injectSheet.test.js' { - declare module.exports: $Exports<'react-jss/lib/injectSheet.test'>; -} -declare module 'react-jss/lib/jss.js' { - declare module.exports: $Exports<'react-jss/lib/jss'>; -} -declare module 'react-jss/lib/JssProvider.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider'>; -} -declare module 'react-jss/lib/JssProvider.test.js' { - declare module.exports: $Exports<'react-jss/lib/JssProvider.test'>; -} -declare module 'react-jss/lib/ns.js' { - declare module.exports: $Exports<'react-jss/lib/ns'>; -} -declare module 'react-jss/lib/propTypes.js' { - declare module.exports: $Exports<'react-jss/lib/propTypes'>; -} diff --git a/scm-plugins/scm-svn-plugin/package.json b/scm-plugins/scm-svn-plugin/package.json index b05332e6ca..1798c0b2e5 100644 --- a/scm-plugins/scm-svn-plugin/package.json +++ b/scm-plugins/scm-svn-plugin/package.json @@ -9,6 +9,6 @@ "@scm-manager/ui-extensions": "^0.0.7" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17" + "@scm-manager/ui-bundler": "^0.0.19" } } diff --git a/scm-plugins/scm-svn-plugin/pom.xml b/scm-plugins/scm-svn-plugin/pom.xml index 6d99ff713c..395def8c27 100644 --- a/scm-plugins/scm-svn-plugin/pom.xml +++ b/scm-plugins/scm-svn-plugin/pom.xml @@ -37,11 +37,19 @@ - - - + + + sonia.scm.maven + smp-maven-plugin + + true + + + + + org.apache.maven.plugins maven-jar-plugin @@ -55,34 +63,6 @@ - - com.github.sdorra - buildfrontend-maven-plugin - - - link-ui-types - process-sources - - install-link - - - @scm-manager/ui-types - - - - link-ui-components - process-sources - - install-link - - - @scm-manager/ui-components - - - - - - diff --git a/scm-plugins/scm-svn-plugin/yarn.lock b/scm-plugins/scm-svn-plugin/yarn.lock index c3e8cc476f..977d642f6f 100644 --- a/scm-plugins/scm-svn-plugin/yarn.lock +++ b/scm-plugins/scm-svn-plugin/yarn.lock @@ -641,9 +641,9 @@ version "0.0.2" resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" diff --git a/scm-ui-components/packages/ui-components/flow-typed/npm/react-i18next_v7.x.x.js b/scm-ui-components/packages/ui-components/flow-typed/npm/react-i18next_v7.x.x.js new file mode 100644 index 0000000000..93d27674d7 --- /dev/null +++ b/scm-ui-components/packages/ui-components/flow-typed/npm/react-i18next_v7.x.x.js @@ -0,0 +1,95 @@ +// flow-typed signature: 65d42f62f8de603dcc631ea5a6b00580 +// flow-typed version: f3f13164e0/react-i18next_v7.x.x/flow_>=v0.64.x + +declare module "react-i18next" { + declare type TFunction = (key?: ?string, data?: ?Object) => string; + + declare type TranslatorProps = {| + t: TFunction, + i18nLoadedAt: Date, + i18n: Object + |}; + + declare type TranslatorPropsVoid = { + t: TFunction | void, + i18nLoadedAt: Date | void, + i18n: Object | void + }; + + declare type Translator> = ( + WrappedComponent: Component + ) => React$ComponentType< + $Diff, TranslatorPropsVoid> + >; + + declare type TranslateOptions = $Shape<{ + wait: boolean, + nsMode: "default" | "fallback", + bindi18n: false | string, + bindStore: false | string, + withRef: boolean, + translateFuncName: string, + i18n: Object, + usePureComponent: boolean + }>; + + declare function translate>( + namespaces?: | string + | Array + | (($Diff) => string | Array), + options?: TranslateOptions + ): Translator; + + declare type I18nProps = { + i18n?: Object, + ns?: string | Array, + children: (t: TFunction, { i18n: Object, t: TFunction }) => React$Node, + initialI18nStore?: Object, + initialLanguage?: string + }; + declare var I18n: React$ComponentType; + + declare type InterpolateProps = { + className?: string, + dangerouslySetInnerHTMLPartElement?: string, + i18n?: Object, + i18nKey?: string, + options?: Object, + parent?: string, + style?: Object, + t?: TFunction, + useDangerouslySetInnerHTML?: boolean + }; + declare var Interpolate: React$ComponentType; + + declare type TransProps = { + count?: number, + parent?: string, + i18n?: Object, + i18nKey?: string, + t?: TFunction + }; + declare var Trans: React$ComponentType; + + declare type ProviderProps = { i18n: Object, children: React$Element<*> }; + declare var I18nextProvider: React$ComponentType; + + declare type NamespacesProps = { + components: Array>, + i18n: { loadNamespaces: Function } + }; + declare function loadNamespaces(props: NamespacesProps): Promise; + + declare var reactI18nextModule: { + type: "3rdParty", + init: (instance: Object) => void + }; + + declare function setDefaults(options: TranslateOptions): void; + + declare function getDefaults(): TranslateOptions; + + declare function getI18n(): Object; + + declare function setI18n(instance: Object): void; +} diff --git a/scm-ui-components/packages/ui-components/package.json b/scm-ui-components/packages/ui-components/package.json index 096a8636b3..3d52d16173 100644 --- a/scm-ui-components/packages/ui-components/package.json +++ b/scm-ui-components/packages/ui-components/package.json @@ -12,7 +12,7 @@ "eslint-fix": "eslint src --fix" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17", + "@scm-manager/ui-bundler": "^0.0.19", "create-index": "^2.3.0", "enzyme": "^3.5.0", "enzyme-adapter-react-16": "^1.3.1", diff --git a/scm-ui-components/packages/ui-components/src/apiclient.js b/scm-ui-components/packages/ui-components/src/apiclient.js index 0b57abeada..bd19dcdf14 100644 --- a/scm-ui-components/packages/ui-components/src/apiclient.js +++ b/scm-ui-components/packages/ui-components/src/apiclient.js @@ -48,6 +48,14 @@ class ApiClient { return this.httpRequestWithJSONBody("PUT", url, contentType, payload); } + head(url: string) { + let options: RequestOptions = { + method: "HEAD" + }; + options = Object.assign(options, fetchOptions); + return fetch(createUrl(url), options).then(handleStatusCode); + } + delete(url: string): Promise { let options: RequestOptions = { method: "DELETE" diff --git a/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js b/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js new file mode 100644 index 0000000000..3a99dc876b --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js @@ -0,0 +1,25 @@ +//@flow +import React from "react"; +import Button, { type ButtonProps } from "./Button"; +import type {File} from "@scm-manager/ui-types"; + +type Props = { + displayName: string, + url: string +}; + +class DownloadButton extends React.Component { + render() { + const {displayName, url} = this.props; + return ( + + + + + {displayName} + + ); + } +} + +export default DownloadButton; diff --git a/scm-ui-components/packages/ui-components/src/buttons/index.js b/scm-ui-components/packages/ui-components/src/buttons/index.js index d7da320fc2..2e166e1d93 100644 --- a/scm-ui-components/packages/ui-components/src/buttons/index.js +++ b/scm-ui-components/packages/ui-components/src/buttons/index.js @@ -7,4 +7,4 @@ export { default as DeleteButton } from "./DeleteButton.js"; export { default as EditButton } from "./EditButton.js"; export { default as RemoveEntryOfTableButton } from "./RemoveEntryOfTableButton.js"; export { default as SubmitButton } from "./SubmitButton.js"; - +export {default as DownloadButton} from "./DownloadButton.js"; diff --git a/scm-ui-components/packages/ui-components/yarn.lock b/scm-ui-components/packages/ui-components/yarn.lock index b4b0cc32a8..0200fdd1bf 100644 --- a/scm-ui-components/packages/ui-components/yarn.lock +++ b/scm-ui-components/packages/ui-components/yarn.lock @@ -641,9 +641,9 @@ version "0.0.2" resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" diff --git a/scm-ui-components/packages/ui-types/package.json b/scm-ui-components/packages/ui-types/package.json index 0701870562..122b1ba504 100644 --- a/scm-ui-components/packages/ui-types/package.json +++ b/scm-ui-components/packages/ui-types/package.json @@ -14,7 +14,7 @@ "check": "flow check" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17" + "@scm-manager/ui-bundler": "^0.0.19" }, "browserify": { "transform": [ diff --git a/scm-ui-components/packages/ui-types/yarn.lock b/scm-ui-components/packages/ui-types/yarn.lock index 58b579d6ae..4f7257e8bb 100644 --- a/scm-ui-components/packages/ui-types/yarn.lock +++ b/scm-ui-components/packages/ui-types/yarn.lock @@ -707,9 +707,9 @@ version "0.0.2" resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" diff --git a/scm-ui/package.json b/scm-ui/package.json index 8a05cb93f8..69ca90a5af 100644 --- a/scm-ui/package.json +++ b/scm-ui/package.json @@ -27,6 +27,7 @@ "react-redux": "^5.0.7", "react-router-dom": "^4.3.1", "react-router-redux": "^5.0.0-alpha.9", + "react-syntax-highlighter": "^9.0.1", "redux": "^4.0.0", "redux-devtools-extension": "^2.13.5", "redux-logger": "^3.0.6", @@ -47,7 +48,7 @@ "pre-commit": "jest && flow && eslint src" }, "devDependencies": { - "@scm-manager/ui-bundler": "^0.0.17", + "@scm-manager/ui-bundler": "^0.0.19", "copyfiles": "^2.0.0", "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.1.1", diff --git a/scm-ui/public/index.mustache b/scm-ui/public/index.mustache index 802be2ca97..62a40d8e93 100644 --- a/scm-ui/public/index.mustache +++ b/scm-ui/public/index.mustache @@ -36,5 +36,9 @@ + + {{#liveReloadURL}} + + {{/liveReloadURL}} diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index 60ee220318..d4fd950c45 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -51,7 +51,11 @@ "name": "Name", "length": "Length", "lastModified": "Last modified", - "description": "Description" + "description": "Description", + "branch": "Branch" + }, + "content": { + "downloadButton": "Download" } }, "changesets": { diff --git a/scm-ui/src/config/containers/GlobalConfig.js b/scm-ui/src/config/containers/GlobalConfig.js index 252e880a42..6046aa4a09 100644 --- a/scm-ui/src/config/containers/GlobalConfig.js +++ b/scm-ui/src/config/containers/GlobalConfig.js @@ -14,7 +14,7 @@ import { modifyConfigReset } from "../modules/config"; import { connect } from "react-redux"; -import type { Config, Link } from "@scm-manager/ui-types"; +import type { Config } from "@scm-manager/ui-types"; import ConfigForm from "../components/form/ConfigForm"; import { getConfigLink } from "../../modules/indexResource"; diff --git a/scm-ui/src/config/modules/config.test.js b/scm-ui/src/config/modules/config.test.js index 12c6b347c3..b6c97826b0 100644 --- a/scm-ui/src/config/modules/config.test.js +++ b/scm-ui/src/config/modules/config.test.js @@ -22,7 +22,6 @@ import reducer, { getConfig, getConfigUpdatePermission } from "./config"; -import { getConfigLink } from "../../modules/indexResource"; const CONFIG_URL = "/config"; const URL = "/api/v2" + CONFIG_URL; diff --git a/scm-ui/src/containers/App.js b/scm-ui/src/containers/App.js index 768b1776d4..50fc805eb2 100644 --- a/scm-ui/src/containers/App.js +++ b/scm-ui/src/containers/App.js @@ -19,9 +19,8 @@ import { Footer, Header } from "@scm-manager/ui-components"; -import type { Me, Link } from "@scm-manager/ui-types"; +import type { Me } from "@scm-manager/ui-types"; import { - fetchIndexResources, getConfigLink, getFetchIndexResourcesFailure, getGroupsLink, diff --git a/scm-ui/src/containers/Logout.js b/scm-ui/src/containers/Logout.js index 7875a6b92a..fe6662da42 100644 --- a/scm-ui/src/containers/Logout.js +++ b/scm-ui/src/containers/Logout.js @@ -11,7 +11,7 @@ import { getLogoutFailure } from "../modules/auth"; import { Loading, ErrorPage } from "@scm-manager/ui-components"; -import { fetchIndexResources, getLogoutLink } from "../modules/indexResource"; +import { getLogoutLink } from "../modules/indexResource"; type Props = { authenticated: boolean, diff --git a/scm-ui/src/groups/containers/AddGroup.js b/scm-ui/src/groups/containers/AddGroup.js index bcb19846b8..9b13ac0309 100644 --- a/scm-ui/src/groups/containers/AddGroup.js +++ b/scm-ui/src/groups/containers/AddGroup.js @@ -9,8 +9,7 @@ import { createGroup, isCreateGroupPending, getCreateGroupFailure, - createGroupReset, - getCreateGroupLink + createGroupReset } from "../modules/groups"; import type { Group } from "@scm-manager/ui-types"; import type { History } from "history"; diff --git a/scm-ui/src/index.js b/scm-ui/src/index.js index 3ecd38e6d0..08e3e8a58c 100644 --- a/scm-ui/src/index.js +++ b/scm-ui/src/index.js @@ -14,7 +14,6 @@ import type { BrowserHistory } from "history/createBrowserHistory"; import createReduxStore from "./createReduxStore"; import { ConnectedRouter } from "react-router-redux"; -import PluginLoader from "./containers/PluginLoader"; import { urls } from "@scm-manager/ui-components"; @@ -37,7 +36,7 @@ ReactDOM.render( {/* ConnectedRouter will use the store from Provider automatically */} - + , diff --git a/scm-ui/src/modules/auth.js b/scm-ui/src/modules/auth.js index fd5068aeb8..fe636ac9d3 100644 --- a/scm-ui/src/modules/auth.js +++ b/scm-ui/src/modules/auth.js @@ -7,8 +7,8 @@ import { isPending } from "./pending"; import { getFailure } from "./failure"; import { callFetchIndexResources, - FETCH_INDEXRESOURCES_SUCCESS, - fetchIndexResources, fetchIndexResourcesPending, + fetchIndexResources, + fetchIndexResourcesPending, fetchIndexResourcesSuccess } from "./indexResource"; @@ -156,7 +156,7 @@ export const login = ( return apiClient .post(loginLink, login_data) .then(response => { - dispatch(fetchIndexResourcesPending()) + dispatch(fetchIndexResourcesPending()); return callFetchIndexResources(); }) .then(response => { diff --git a/scm-ui/src/repos/components/list/RepositoryEntry.js b/scm-ui/src/repos/components/list/RepositoryEntry.js index ef1df0d3d9..bc170144aa 100644 --- a/scm-ui/src/repos/components/list/RepositoryEntry.js +++ b/scm-ui/src/repos/components/list/RepositoryEntry.js @@ -1,9 +1,9 @@ //@flow import React from "react"; -import {Link} from "react-router-dom"; +import { Link } from "react-router-dom"; import injectSheet from "react-jss"; -import type {Repository} from "@scm-manager/ui-types"; -import {DateFromNow} from "@scm-manager/ui-components"; +import type { Repository } from "@scm-manager/ui-types"; +import { DateFromNow } from "@scm-manager/ui-components"; import RepositoryEntryLink from "./RepositoryEntryLink"; import classNames from "classnames"; import RepositoryAvatar from "./RepositoryAvatar"; @@ -45,7 +45,7 @@ class RepositoryEntry extends React.Component { return ( ); } diff --git a/scm-ui/src/repos/sources/components/FileTree.js b/scm-ui/src/repos/sources/components/FileTree.js index 02aa22f942..e9b5c70d3d 100644 --- a/scm-ui/src/repos/sources/components/FileTree.js +++ b/scm-ui/src/repos/sources/components/FileTree.js @@ -7,7 +7,6 @@ import FileTreeLeaf from "./FileTreeLeaf"; import type { Repository, File } from "@scm-manager/ui-types"; import { ErrorNotification, Loading } from "@scm-manager/ui-components"; import { - fetchSources, getFetchSourcesFailure, isFetchSourcesPending, getSources @@ -29,7 +28,6 @@ type Props = { revision: string, path: string, baseUrl: string, - fetchSources: (Repository, string, string) => void, // context props classes: any, t: string => string, @@ -49,19 +47,6 @@ export function findParent(path: string) { } class FileTree extends React.Component { - componentDidMount() { - const { fetchSources, repository, revision, path } = this.props; - - fetchSources(repository, revision, path); - } - - componentDidUpdate(prevProps) { - const { fetchSources, repository, revision, path } = this.props; - if (prevProps.revision !== revision || prevProps.path !== path) { - fetchSources(repository, revision, path); - } - } - render() { const { error, @@ -167,18 +152,7 @@ const mapStateToProps = (state: any, ownProps: Props) => { }; }; -const mapDispatchToProps = dispatch => { - return { - fetchSources: (repository: Repository, revision: string, path: string) => { - dispatch(fetchSources(repository, revision, path)); - } - }; -}; - export default compose( withRouter, - connect( - mapStateToProps, - mapDispatchToProps - ) + connect(mapStateToProps) )(injectSheet(styles)(translate("repos")(FileTree))); diff --git a/scm-ui/src/repos/sources/components/FileTreeLeaf.js b/scm-ui/src/repos/sources/components/FileTreeLeaf.js index 033d3b9b8a..b4e2ad59ea 100644 --- a/scm-ui/src/repos/sources/components/FileTreeLeaf.js +++ b/scm-ui/src/repos/sources/components/FileTreeLeaf.js @@ -49,14 +49,18 @@ class FileTreeLeaf extends React.Component { ); } - return ; + return ( + + + + ); }; createFileName = (file: File) => { if (file.directory) { return {file.name}; } - return file.name; + return {file.name}; }; render() { diff --git a/scm-ui/src/repos/sources/components/content/DownloadViewer.js b/scm-ui/src/repos/sources/components/content/DownloadViewer.js new file mode 100644 index 0000000000..4b84d7a53d --- /dev/null +++ b/scm-ui/src/repos/sources/components/content/DownloadViewer.js @@ -0,0 +1,26 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import type { File } from "@scm-manager/ui-types"; +import { DownloadButton } from "@scm-manager/ui-components"; + +type Props = { + t: string => string, + file: File +}; + +class DownloadViewer extends React.Component { + render() { + const { t, file } = this.props; + return ( +
+ +
+ ); + } +} + +export default translate("repos")(DownloadViewer); diff --git a/scm-ui/src/repos/sources/components/content/ImageViewer.js b/scm-ui/src/repos/sources/components/content/ImageViewer.js new file mode 100644 index 0000000000..67003fa357 --- /dev/null +++ b/scm-ui/src/repos/sources/components/content/ImageViewer.js @@ -0,0 +1,24 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import type { File } from "@scm-manager/ui-types"; + +type Props = { + t: string => string, + file: File +}; + +class ImageViewer extends React.Component { + render() { + const { file } = this.props; + return ( +
+
+ {file._links.self.href} +
+
+ ); + } +} + +export default translate("repos")(ImageViewer); diff --git a/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js new file mode 100644 index 0000000000..e54f8e1b3b --- /dev/null +++ b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js @@ -0,0 +1,97 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { apiClient } from "@scm-manager/ui-components"; +import type { File } from "@scm-manager/ui-types"; +import { ErrorNotification, Loading } from "@scm-manager/ui-components"; +import SyntaxHighlighter from "react-syntax-highlighter"; +import { arduinoLight } from "react-syntax-highlighter/styles/hljs"; + +type Props = { + t: string => string, + file: File, + language: string +}; + +type State = { + content: string, + error?: Error, + loaded: boolean +}; + +class SourcecodeViewer extends React.Component { + constructor(props: Props) { + super(props); + + this.state = { + content: "", + loaded: false + }; + } + + componentDidMount() { + const { file } = this.props; + getContent(file._links.self.href) + .then(result => { + if (result.error) { + this.setState({ + ...this.state, + error: result.error, + loaded: true + }); + } else { + this.setState({ + ...this.state, + content: result, + loaded: true + }); + } + }) + .catch(err => {}); + } + + render() { + const { content, error, loaded } = this.state; + const language = this.props.language; + + if (error) { + return ; + } + + if (!loaded) { + return ; + } + + if (!content) { + return null; + } + + return ( + + {content} + + ); + } +} + +export function getLanguage(language: string) { + return language.toLowerCase(); +} + +export function getContent(url: string) { + return apiClient + .get(url) + .then(response => response.text()) + .then(response => { + return response; + }) + .catch(err => { + return { error: err }; + }); +} + +export default translate("repos")(SourcecodeViewer); diff --git a/scm-ui/src/repos/sources/components/content/SourcecodeViewer.test.js b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.test.js new file mode 100644 index 0000000000..11e701f626 --- /dev/null +++ b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.test.js @@ -0,0 +1,33 @@ +//@flow +import fetchMock from "fetch-mock"; +import { + getContent, + getLanguage +} from "./SourcecodeViewer"; + +describe("get content", () => { + const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent"; + + afterEach(() => { + fetchMock.reset(); + fetchMock.restore(); + }); + + it("should return content", done => { + fetchMock.getOnce("/api/v2" + CONTENT_URL, "This is a testContent"); + + getContent(CONTENT_URL).then(content => { + expect(content).toBe("This is a testContent"); + done(); + }); + }); +}); + +describe("get correct language type", () => { + it("should return javascript", () => { + expect(getLanguage("JAVASCRIPT")).toBe("javascript"); + }); + it("should return nothing for plain text", () => { + expect(getLanguage("")).toBe(""); + }); +}); diff --git a/scm-ui/src/repos/sources/containers/Content.js b/scm-ui/src/repos/sources/containers/Content.js new file mode 100644 index 0000000000..0b764aa6a1 --- /dev/null +++ b/scm-ui/src/repos/sources/containers/Content.js @@ -0,0 +1,217 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { getSources } from "../modules/sources"; +import type { Repository, File } from "@scm-manager/ui-types"; +import { + ErrorNotification, + Loading, + DateFromNow +} from "@scm-manager/ui-components"; +import { connect } from "react-redux"; +import ImageViewer from "../components/content/ImageViewer"; +import SourcecodeViewer from "../components/content/SourcecodeViewer"; +import DownloadViewer from "../components/content/DownloadViewer"; +import FileSize from "../components/FileSize"; +import injectSheet from "react-jss"; +import classNames from "classnames"; +import { ExtensionPoint } from "@scm-manager/ui-extensions"; +import { getContentType } from "./contentType"; + +type Props = { + loading: boolean, + error: Error, + file: File, + repository: Repository, + revision: string, + path: string, + classes: any, + t: string => string +}; + +type State = { + contentType: string, + language: string, + loaded: boolean, + collapsed: boolean, + error?: Error +}; + +const styles = { + toCenterContent: { + display: "block" + }, + pointer: { + cursor: "pointer" + } +}; + +class Content extends React.Component { + constructor(props: Props) { + super(props); + + this.state = { + contentType: "", + language: "", + loaded: false, + collapsed: true + }; + } + + componentDidMount() { + const { file } = this.props; + getContentType(file._links.self.href) + .then(result => { + if (result.error) { + this.setState({ + ...this.state, + error: result.error, + loaded: true + }); + } else { + this.setState({ + ...this.state, + contentType: result.type, + language: result.language, + loaded: true + }); + } + }) + .catch(err => {}); + } + + toggleCollapse = () => { + this.setState(prevState => ({ + collapsed: !prevState.collapsed + })); + }; + + showHeader() { + const { file, classes } = this.props; + const collapsed = this.state.collapsed; + const icon = collapsed ? "fa-angle-right" : "fa-angle-down"; + const fileSize = file.directory ? "" : ; + + return ( + +
+
+ +
+
+
{file.name}
+
+

{fileSize}

+
+
+ ); + } + + showMoreInformation() { + const collapsed = this.state.collapsed; + const { classes, file, revision } = this.props; + const date = ; + const description = file.description ? ( +

+ {file.description.split("\n").map((item, key) => { + return ( + + {item} +
+
+ ); + })} +

+ ) : null; + if (!collapsed) { + return ( +
+ + + + + + + + + + + + + + + + + + + +
Path{file.path}
Branch{revision}
Last modified{date}
Description{description}
+
+ ); + } + return null; + } + + showContent() { + const { file, revision } = this.props; + const { contentType, language } = this.state; + if (contentType.startsWith("image/")) { + return ; + } else if (language) { + return ; + } else if (contentType.startsWith("text/")) { + return ; + } else { + return ( + + + + ); + } + } + + render() { + const { file, classes } = this.props; + const { loaded, error } = this.state; + + if (!file || !loaded) { + return ; + } + if (error) { + return ; + } + + const header = this.showHeader(); + const content = this.showContent(); + const moreInformation = this.showMoreInformation(); + + return ( +
+ +
+ ); + } +} + +const mapStateToProps = (state: any, ownProps: Props) => { + const { repository, revision, path } = ownProps; + + const file = getSources(state, repository, revision, path); + + return { + file + }; +}; + +export default injectSheet(styles)( + connect(mapStateToProps)(translate("repos")(Content)) +); diff --git a/scm-ui/src/repos/sources/containers/Sources.js b/scm-ui/src/repos/sources/containers/Sources.js index cf072e958e..1a9f1d62e7 100644 --- a/scm-ui/src/repos/sources/containers/Sources.js +++ b/scm-ui/src/repos/sources/containers/Sources.js @@ -13,6 +13,8 @@ import { isFetchBranchesPending } from "../../modules/branches"; import { compose } from "redux"; +import Content from "./Content"; +import { fetchSources, isDirectory } from "../modules/sources"; type Props = { repository: Repository, @@ -22,9 +24,11 @@ type Props = { branches: Branch[], revision: string, path: string, + currentFileIsDirectory: boolean, // dispatch props fetchBranches: Repository => void, + fetchSources: (Repository, string, string) => void, // Context props history: any, @@ -33,14 +37,26 @@ type Props = { class Sources extends React.Component { componentDidMount() { - const { fetchBranches, repository } = this.props; + const { + fetchBranches, + repository, + revision, + path, + fetchSources + } = this.props; fetchBranches(repository); + fetchSources(repository, revision, path); + } + componentDidUpdate(prevProps) { + const { fetchSources, repository, revision, path } = this.props; + if (prevProps.revision !== revision || prevProps.path !== path) { + fetchSources(repository, revision, path); + } } branchSelected = (branch?: Branch) => { const { baseUrl, history, path } = this.props; - let url; if (branch) { if (path) { @@ -55,7 +71,15 @@ class Sources extends React.Component { }; render() { - const { repository, baseUrl, loading, error, revision, path } = this.props; + const { + repository, + baseUrl, + loading, + error, + revision, + path, + currentFileIsDirectory + } = this.props; if (error) { return ; @@ -65,21 +89,28 @@ class Sources extends React.Component { return ; } - return ( - <> - {this.renderBranchSelector()} - - - ); + if (currentFileIsDirectory) { + return ( + <> + {this.renderBranchSelector()} + + + ); + } else { + return ( + + ); + } } renderBranchSelector = () => { const { repository, branches, revision } = this.props; + if (repository._links.branches) { return ( { const { repository, match } = ownProps; const { revision, path } = match.params; const decodedRevision = revision ? decodeURIComponent(revision) : undefined; - const loading = isFetchBranchesPending(state, repository); const error = getFetchBranchesFailure(state, repository); const branches = getBranches(state, repository); + const currentFileIsDirectory = decodedRevision + ? isDirectory(state, repository, decodedRevision, path) + : isDirectory(state, repository, revision, path); return { repository, @@ -110,7 +143,8 @@ const mapStateToProps = (state, ownProps) => { path, loading, error, - branches + branches, + currentFileIsDirectory }; }; @@ -118,6 +152,9 @@ const mapDispatchToProps = dispatch => { return { fetchBranches: (repository: Repository) => { dispatch(fetchBranches(repository)); + }, + fetchSources: (repository: Repository, revision: string, path: string) => { + dispatch(fetchSources(repository, revision, path)); } }; }; diff --git a/scm-ui/src/repos/sources/containers/contentType.js b/scm-ui/src/repos/sources/containers/contentType.js new file mode 100644 index 0000000000..bf9888834b --- /dev/null +++ b/scm-ui/src/repos/sources/containers/contentType.js @@ -0,0 +1,16 @@ +//@flow +import { apiClient } from "@scm-manager/ui-components"; + +export function getContentType(url: string) { + return apiClient + .head(url) + .then(response => { + return { + type: response.headers.get("Content-Type"), + language: response.headers.get("X-Programming-Language") + }; + }) + .catch(err => { + return { error: err }; + }); +} diff --git a/scm-ui/src/repos/sources/containers/contentType.test.js b/scm-ui/src/repos/sources/containers/contentType.test.js new file mode 100644 index 0000000000..c3ab85ed80 --- /dev/null +++ b/scm-ui/src/repos/sources/containers/contentType.test.js @@ -0,0 +1,29 @@ +//@flow +import fetchMock from "fetch-mock"; +import { getContentType } from "./contentType"; + +describe("get content type", () => { + const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent"; + + afterEach(() => { + fetchMock.reset(); + fetchMock.restore(); + }); + + it("should return content", done => { + let headers = { + "Content-Type": "application/text", + "X-Programming-Language": "JAVA" + }; + + fetchMock.head("/api/v2" + CONTENT_URL, { + headers + }); + + getContentType(CONTENT_URL).then(content => { + expect(content.type).toBe("application/text"); + expect(content.language).toBe("JAVA"); + done(); + }); + }); +}); diff --git a/scm-ui/src/repos/sources/modules/sources.js b/scm-ui/src/repos/sources/modules/sources.js index 719770d75c..641c1550b6 100644 --- a/scm-ui/src/repos/sources/modules/sources.js +++ b/scm-ui/src/repos/sources/modules/sources.js @@ -102,6 +102,20 @@ export default function reducer( // selectors +export function isDirectory( + state: any, + repository: Repository, + revision: string, + path: string +): boolean { + const currentFile = getSources(state, repository, revision, path); + if (currentFile && !currentFile.directory) { + return false; + } else { + return true; //also return true if no currentFile is found since it is the "default" path + } +} + export function getSources( state: any, repository: Repository, diff --git a/scm-ui/src/repos/sources/modules/sources.test.js b/scm-ui/src/repos/sources/modules/sources.test.js index 068fa39e8f..1a5c81e908 100644 --- a/scm-ui/src/repos/sources/modules/sources.test.js +++ b/scm-ui/src/repos/sources/modules/sources.test.js @@ -1,6 +1,6 @@ // @flow -import type { Repository } from "@scm-manager/ui-types"; +import type { Repository, File } from "@scm-manager/ui-types"; import configureMockStore from "redux-mock-store"; import thunk from "redux-thunk"; import fetchMock from "fetch-mock"; @@ -14,7 +14,8 @@ import { isFetchSourcesPending, default as reducer, getSources, - fetchSourcesSuccess + fetchSourcesSuccess, + isDirectory } from "./sources"; const sourcesUrl = @@ -79,6 +80,21 @@ const collection = { } }; +const noDirectory: File = { + name: "src", + path: "src", + directory: true, + length: 176, + revision: "abc", + _links: { + self: { + href: + "http://localhost:8081/scm/rest/api/v2/repositories/scm/core/sources/76aae4bb4ceacf0e88938eb5b6832738b7d537b4/src" + } + }, + _embedded: collection +}; + describe("sources fetch", () => { const mockStore = configureMockStore([thunk]); @@ -168,6 +184,28 @@ describe("reducer tests", () => { }); describe("selector tests", () => { + it("should return false if it is no directory", () => { + const state = { + sources: { + "scm/core/abc/src/main/package.json": { + noDirectory + } + } + }; + expect( + isDirectory(state, repository, "abc", "src/main/package.json") + ).toBeFalsy(); + }); + + it("should return true if it is directory", () => { + const state = { + sources: { + "scm/core/abc/src": noDirectory + } + }; + expect(isDirectory(state, repository, "abc", "src")).toBe(true); + }); + it("should return null", () => { expect(getSources({}, repository)).toBeFalsy(); }); @@ -181,7 +219,7 @@ describe("selector tests", () => { expect(getSources(state, repository)).toBe(collection); }); - it("should return the source collection without revision and path", () => { + it("should return the source collection with revision and path", () => { const state = { sources: { "scm/core/abc/src/main": collection diff --git a/scm-ui/yarn.lock b/scm-ui/yarn.lock index 6318b3c8b3..adfc1a3265 100644 --- a/scm-ui/yarn.lock +++ b/scm-ui/yarn.lock @@ -727,9 +727,9 @@ resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85" integrity sha512-0Xp8yMaK4RA7nxgF5/Q8hC7ATfwHZLtGogPeEAEHyT+HI5HqWeQpwd+vPuoD1QveoypNDjqDoctmFKdzi26Q+Q== -"@scm-manager/ui-bundler@^0.0.17": - version "0.0.17" - resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.17.tgz#949b90ca57e4268be28fcf4975bd9622f60278bb" +"@scm-manager/ui-bundler@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae" integrity sha512-k8Hp73HlF+Me3l0ZwmU0SPVadYgYSBL5/bE/9PASO+mdm7dfkjgPIvOPfdXT8GlWwzFt0RIk7ROMf4UEr7Q1ow== dependencies: "@babel/core" "^7.0.0" @@ -1352,7 +1352,7 @@ babel-register@^6.26.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@^6.22.0, babel-runtime@^6.26.0: +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= @@ -1990,6 +1990,18 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +character-entities-legacy@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/character-entities-legacy/-/character-entities-legacy-1.1.2.tgz#7c6defb81648498222c9855309953d05f4d63a9c" + +character-entities@^1.0.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/character-entities/-/character-entities-1.2.2.tgz#58c8f371c0774ef0ba9b2aca5f00d8f100e6e363" + +character-reference-invalid@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.2.tgz#21e421ad3d84055952dab4a43a04e73cd425d3ed" + chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" @@ -2105,6 +2117,14 @@ cli-width@^2.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= +clipboard@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-2.0.1.tgz#a12481e1c13d8a50f5f036b0560fe5d16d74e46a" + dependencies: + good-listener "^1.2.2" + select "^1.1.2" + tiny-emitter "^2.0.0" + cliui@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" @@ -2231,6 +2251,12 @@ combined-stream@^1.0.5, combined-stream@~1.0.5, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +comma-separated-tokens@^1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.5.tgz#b13793131d9ea2d2431cf5b507ddec258f0ce0db" + dependencies: + trim "0.0.1" + commander@^2.11.0, commander@^2.17.1, commander@^2.2.0, commander@^2.9.0: version "2.18.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" @@ -2675,6 +2701,10 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= +delegate@^3.1.2: + version "3.2.0" + resolved "https://registry.yarnpkg.com/delegate/-/delegate-3.2.0.tgz#b66b71c3158522e8ab5744f720d8ca0c2af59166" + delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" @@ -3533,6 +3563,12 @@ fast-xml-parser@^3.12.0: dependencies: nimnjs "^1.3.2" +fault@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.2.tgz#c3d0fec202f172a3a4d414042ad2bb5e2a3ffbaa" + dependencies: + format "^0.2.2" + fb-watchman@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58" @@ -3775,6 +3811,10 @@ form-data@~2.3.1, form-data@~2.3.2: combined-stream "1.0.6" mime-types "^2.1.12" +format@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b" + fragment-cache@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" @@ -4124,6 +4164,12 @@ glogg@^1.0.0: dependencies: sparkles "^1.0.0" +good-listener@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50" + dependencies: + delegate "^3.1.2" + got@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" @@ -4401,6 +4447,19 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" +hast-util-parse-selector@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-2.2.0.tgz#2175f18cdd697308fc3431d5c29a9e48dfa4817a" + +hastscript@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/hastscript/-/hastscript-4.1.0.tgz#ea5593fa6f6709101fc790ced818393ddaa045ce" + dependencies: + comma-separated-tokens "^1.0.0" + hast-util-parse-selector "^2.2.0" + property-information "^4.0.0" + space-separated-tokens "^1.0.0" + hawk@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" @@ -4411,6 +4470,10 @@ hawk@~3.1.3: hoek "2.x.x" sntp "1.x.x" +highlight.js@~9.12.0: + version "9.12.0" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e" + history@^4.7.2: version "4.7.2" resolved "https://registry.yarnpkg.com/history/-/history-4.7.2.tgz#22b5c7f31633c5b8021c7f4a8a954ac139ee8d5b" @@ -4759,6 +4822,17 @@ is-accessor-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" +is-alphabetical@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-alphabetical/-/is-alphabetical-1.0.2.tgz#1fa6e49213cb7885b75d15862fb3f3d96c884f41" + +is-alphanumerical@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-alphanumerical/-/is-alphanumerical-1.0.2.tgz#1138e9ae5040158dc6ff76b820acd6b7a181fd40" + dependencies: + is-alphabetical "^1.0.0" + is-decimal "^1.0.0" + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" @@ -4819,6 +4893,10 @@ is-date-object@^1.0.1: resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= +is-decimal@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-decimal/-/is-decimal-1.0.2.tgz#894662d6a8709d307f3a276ca4339c8fa5dff0ff" + is-descriptor@^0.1.0: version "0.1.6" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" @@ -4921,6 +4999,10 @@ is-glob@^4.0.0: dependencies: is-extglob "^2.1.1" +is-hexadecimal@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-hexadecimal/-/is-hexadecimal-1.0.2.tgz#b6e710d7d07bb66b98cb8cece5c9b4921deeb835" + is-in-browser@^1.0.2, is-in-browser@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/is-in-browser/-/is-in-browser-1.1.3.tgz#56ff4db683a078c6082eb95dad7dc62e1d04f835" @@ -6168,6 +6250,13 @@ lowercase-keys@^1.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== +lowlight@~1.9.1: + version "1.9.2" + resolved "https://registry.yarnpkg.com/lowlight/-/lowlight-1.9.2.tgz#0b9127e3cec2c3021b7795dd81005c709a42fdd1" + dependencies: + fault "^1.0.2" + highlight.js "~9.12.0" + lru-cache@2: version "2.7.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" @@ -7167,6 +7256,17 @@ parse-asn1@^5.0.0: evp_bytestokey "^1.0.0" pbkdf2 "^3.0.3" +parse-entities@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-1.2.0.tgz#9deac087661b2e36814153cb78d7e54a4c5fd6f4" + dependencies: + character-entities "^1.0.0" + character-entities-legacy "^1.0.0" + character-reference-invalid "^1.0.0" + is-alphanumerical "^1.0.0" + is-decimal "^1.0.0" + is-hexadecimal "^1.0.0" + parse-filepath@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891" @@ -7500,6 +7600,12 @@ pretty-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= +prismjs@^1.8.4, prismjs@~1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.15.0.tgz#8801d332e472091ba8def94976c8877ad60398d9" + optionalDependencies: + clipboard "^2.0.0" + private@^0.1.6, private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -7541,6 +7647,12 @@ prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2: loose-envify "^1.3.1" object-assign "^4.1.1" +property-information@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/property-information/-/property-information-4.2.0.tgz#f0e66e07cbd6fed31d96844d958d153ad3eb486e" + dependencies: + xtend "^4.0.1" + ps-tree@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.0.tgz#b421b24140d6203f1ed3c76996b4427b08e8c014" @@ -7781,6 +7893,16 @@ react-router@^4.2.0, react-router@^4.3.1: prop-types "^15.6.1" warning "^4.0.1" +react-syntax-highlighter@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/react-syntax-highlighter/-/react-syntax-highlighter-9.0.1.tgz#cad91692e1976f68290f24762ac3451b1fec3d26" + dependencies: + babel-runtime "^6.18.0" + highlight.js "~9.12.0" + lowlight "~1.9.1" + prismjs "^1.8.4" + refractor "^2.4.1" + react-test-renderer@^16.0.0-0, react-test-renderer@^16.4.1: version "16.5.2" resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.5.2.tgz#92e9d2c6f763b9821b2e0b22f994ee675068b5ae" @@ -7967,6 +8089,14 @@ redux@^4.0.0: loose-envify "^1.1.0" symbol-observable "^1.2.0" +refractor@^2.4.1: + version "2.6.0" + resolved "https://registry.yarnpkg.com/refractor/-/refractor-2.6.0.tgz#6b0d88f654c8534eefed3329a35bc7bb74ae0979" + dependencies: + hastscript "^4.0.0" + parse-entities "^1.1.2" + prismjs "~1.15.0" + regenerate-unicode-properties@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-7.0.0.tgz#107405afcc4a190ec5ed450ecaa00ed0cafa7a4c" @@ -8382,6 +8512,10 @@ scss-tokenizer@^0.2.3: js-base64 "^2.1.8" source-map "^0.4.2" +select@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" + "semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1: version "5.5.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" @@ -8690,6 +8824,12 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +space-separated-tokens@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.2.tgz#e95ab9d19ae841e200808cd96bc7bd0adbbb3412" + dependencies: + trim "0.0.1" + sparkles@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c" @@ -9149,6 +9289,10 @@ timers-ext@^0.1.5: es5-ext "~0.10.46" next-tick "1" +tiny-emitter@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.0.2.tgz#82d27468aca5ade8e5fd1e6d22b57dd43ebdfb7c" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -9248,6 +9392,10 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= +trim@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd" + "true-case-path@^1.0.2": version "1.0.3" resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-1.0.3.tgz#f813b5a8c86b40da59606722b144e3225799f47d" diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 644a1bc0f9..4dfb749690 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -103,7 +103,6 @@ javax javaee-api 7.0 - test diff --git a/scm-webapp/src/main/java/sonia/scm/ResteasyModule.java b/scm-webapp/src/main/java/sonia/scm/ResteasyModule.java new file mode 100644 index 0000000000..a85c3b6d06 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/ResteasyModule.java @@ -0,0 +1,20 @@ +package sonia.scm; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.servlet.ServletModule; +import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher; +import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; + +import javax.inject.Singleton; +import java.util.Map; + +public class ResteasyModule extends ServletModule { + + @Override + protected void configureServlets() { + bind(HttpServletDispatcher.class).in(Singleton.class); + + Map initParams = ImmutableMap.of(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, "/api"); + serve("/api/*").with(HttpServletDispatcher.class, initParams); + } +} diff --git a/scm-webapp/src/main/java/sonia/scm/ScmContextListener.java b/scm-webapp/src/main/java/sonia/scm/ScmContextListener.java index 5a087a1c70..8ae005e826 100644 --- a/scm-webapp/src/main/java/sonia/scm/ScmContextListener.java +++ b/scm-webapp/src/main/java/sonia/scm/ScmContextListener.java @@ -126,6 +126,7 @@ public class ScmContextListener extends GuiceResteasyBootstrapServletContextList ClassOverrides overrides = ClassOverrides.findOverrides(pluginLoader.getUberClassLoader()); List moduleList = Lists.newArrayList(); + moduleList.add(new ResteasyModule()); moduleList.add(new ScmInitializerModule()); moduleList.add(new ScmEventBusModule()); moduleList.add(new EagerSingletonModule()); diff --git a/scm-webapp/src/main/java/sonia/scm/TemplatingPushStateDispatcher.java b/scm-webapp/src/main/java/sonia/scm/TemplatingPushStateDispatcher.java index 6652975c4a..0888a45dc2 100644 --- a/scm-webapp/src/main/java/sonia/scm/TemplatingPushStateDispatcher.java +++ b/scm-webapp/src/main/java/sonia/scm/TemplatingPushStateDispatcher.java @@ -57,5 +57,9 @@ public class TemplatingPushStateDispatcher implements PushStateDispatcher { return request.getContextPath(); } + public String getLiveReloadURL() { + return System.getProperty("livereload.url"); + } + } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ContentResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ContentResource.java index dc7c305823..99ed29e6f6 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ContentResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ContentResource.java @@ -136,7 +136,7 @@ public class ContentResource { private void appendContentHeader(String path, byte[] head, Response.ResponseBuilder responseBuilder) { ContentType contentType = ContentTypes.detect(path, head); responseBuilder.header("Content-Type", contentType.getRaw()); - contentType.getLanguage().ifPresent(language -> responseBuilder.header("Language", language)); + contentType.getLanguage().ifPresent(language -> responseBuilder.header("X-Programming-Language", language)); } private byte[] getHead(String revision, String path, RepositoryService repositoryService) throws IOException, PathNotFoundException, RevisionNotFoundException { diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextFilter.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextFilter.java index bfa2218e76..aec8e2d653 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextFilter.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextFilter.java @@ -34,22 +34,19 @@ package sonia.scm.boot; //~--- non-JDK imports -------------------------------------------------------- import com.github.legman.Subscribe; - import com.google.inject.servlet.GuiceFilter; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import sonia.scm.SCMContext; import sonia.scm.Stage; import sonia.scm.event.ScmEventBus; -//~--- JDK imports ------------------------------------------------------------ - import javax.servlet.FilterConfig; import javax.servlet.ServletContextEvent; import javax.servlet.ServletException; +//~--- JDK imports ------------------------------------------------------------ + /** * * @author Sebastian Sdorra @@ -65,6 +62,8 @@ public class BootstrapContextFilter extends GuiceFilter //~--- methods -------------------------------------------------------------- + private final BootstrapContextListener listener = new BootstrapContextListener(); + /** * Restart the whole webapp context. * @@ -85,29 +84,20 @@ public class BootstrapContextFilter extends GuiceFilter } else { - - logger.warn( - "destroy filter pipeline, because of a received restart event"); + logger.warn("destroy filter pipeline, because of a received restart event"); destroy(); - logger.warn( - "reinitialize filter pipeline, because of a received restart event"); - super.init(filterConfig); + + logger.warn("reinitialize filter pipeline, because of a received restart event"); + initGuice(); } } - /** - * Method description - * - * - * @param filterConfig - * - * @throws ServletException - */ @Override public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; - super.init(filterConfig); + + initGuice(); if (SCMContext.getContext().getStage() == Stage.DEVELOPMENT) { @@ -116,6 +106,19 @@ public class BootstrapContextFilter extends GuiceFilter } } + public void initGuice() throws ServletException { + super.init(filterConfig); + + listener.contextInitialized(new ServletContextEvent(filterConfig.getServletContext())); + } + + @Override + public void destroy() { + super.destroy(); + listener.contextDestroyed(new ServletContextEvent(filterConfig.getServletContext())); + ServletContextCleaner.cleanup(filterConfig.getServletContext()); + } + //~--- fields --------------------------------------------------------------- /** Field description */ diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextListener.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextListener.java index 4f7a00ce56..afaa28bfe8 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextListener.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapContextListener.java @@ -148,13 +148,15 @@ public class BootstrapContextListener implements ServletContextListener { context = sce.getServletContext(); - PluginIndex index = readCorePluginIndex(context); - File pluginDirectory = getPluginDirectory(); try { - extractCorePlugins(context, pluginDirectory, index); + if (!isCorePluginExtractionDisabled()) { + extractCorePlugins(context, pluginDirectory); + } else { + logger.info("core plugin extraction is disabled"); + } ClassLoader cl = ClassLoaders.getContextClassLoader(BootstrapContextListener.class); @@ -181,31 +183,8 @@ public class BootstrapContextListener implements ServletContextListener } } - /** - * Restart the whole webapp context. - * - * - * @param event restart event - */ - @Subscribe - public void handleRestartEvent(RestartEvent event) - { - logger.warn("received restart event from {} with reason: {}", - event.getCause(), event.getReason()); - - if (context == null) - { - logger.error("context is null, scm-manager is not initialized"); - } - else - { - ServletContextEvent sce = new ServletContextEvent(context); - - logger.warn("destroy context, because of a received restart event"); - contextDestroyed(sce); - logger.warn("reinitialize context, because of a received restart event"); - contextInitialized(sce); - } + private boolean isCorePluginExtractionDisabled() { + return Boolean.getBoolean("sonia.scm.boot.disable-core-plugin-extraction"); } /** @@ -214,7 +193,6 @@ public class BootstrapContextListener implements ServletContextListener * * @param context * @param pluginDirectory - * @param name * @param entry * * @throws IOException @@ -269,17 +247,15 @@ public class BootstrapContextListener implements ServletContextListener * * @param context * @param pluginDirectory - * @param lines - * @param index * * @throws IOException */ - private void extractCorePlugins(ServletContext context, File pluginDirectory, - PluginIndex index) - throws IOException + private void extractCorePlugins(ServletContext context, File pluginDirectory) throws IOException { IOUtil.mkdirs(pluginDirectory); + PluginIndex index = readCorePluginIndex(context); + for (PluginIndexEntry entry : index) { extractCorePlugin(context, pluginDirectory, entry); diff --git a/scm-webapp/src/main/java/sonia/scm/boot/RestartServlet.java b/scm-webapp/src/main/java/sonia/scm/boot/RestartServlet.java new file mode 100644 index 0000000000..c7177cc459 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/boot/RestartServlet.java @@ -0,0 +1,97 @@ +package sonia.scm.boot; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import sonia.scm.Priority; +import sonia.scm.SCMContext; +import sonia.scm.Stage; +import sonia.scm.event.ScmEventBus; +import sonia.scm.filter.WebElement; + +import javax.inject.Inject; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * This servlet sends a {@link RestartEvent} to the {@link ScmEventBus} which causes scm-manager to restart the context. + * The {@link RestartServlet} can be used for reloading java code or for installing plugins without a complete restart. + * At the moment the Servlet accepts only request, if scm-manager was started in the {@link Stage#DEVELOPMENT} stage. + * + * @since 2.0.0 + */ +@Priority(0) +@WebElement("/restart") +public class RestartServlet extends HttpServlet { + + private static final Logger LOG = LoggerFactory.getLogger(RestartServlet.class); + + private final ObjectMapper objectMapper = new ObjectMapper(); + private final AtomicBoolean restarting = new AtomicBoolean(); + + private final ScmEventBus eventBus; + private final Stage stage; + + @Inject + public RestartServlet() { + this(ScmEventBus.getInstance(), SCMContext.getContext().getStage()); + } + + RestartServlet(ScmEventBus eventBus, Stage stage) { + this.eventBus = eventBus; + this.stage = stage; + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) { + LOG.info("received sendRestartEvent request"); + + if (isRestartAllowed()) { + + try (InputStream requestInput = req.getInputStream()) { + Reason reason = objectMapper.readValue(requestInput, Reason.class); + sendRestartEvent(resp, reason); + } catch (IOException ex) { + LOG.warn("failed to trigger sendRestartEvent event", ex); + resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + } else { + LOG.debug("received restart event in non development stage"); + resp.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); + } + } + + private boolean isRestartAllowed() { + return stage == Stage.DEVELOPMENT; + } + + private void sendRestartEvent(HttpServletResponse response, Reason reason) { + if ( restarting.compareAndSet(false, true) ) { + LOG.info("trigger sendRestartEvent, because of {}", reason.getMessage()); + eventBus.post(new RestartEvent(RestartServlet.class, reason.getMessage())); + + response.setStatus(HttpServletResponse.SC_ACCEPTED); + } else { + LOG.warn("scm-manager restarts already"); + response.setStatus(HttpServletResponse.SC_CONFLICT); + } + } + + public static class Reason { + + private String message; + + public void setMessage(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + } +} diff --git a/scm-webapp/src/main/java/sonia/scm/boot/ServletContextCleaner.java b/scm-webapp/src/main/java/sonia/scm/boot/ServletContextCleaner.java new file mode 100644 index 0000000000..8b152ce329 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/boot/ServletContextCleaner.java @@ -0,0 +1,59 @@ +package sonia.scm.boot; + +import com.google.common.collect.ImmutableSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletContext; +import java.util.Enumeration; +import java.util.Set; + +/** + * Remove cached resources from {@link ServletContext} to allow a clean restart of scm-manager without stale or + * duplicated data. + * + * @since 2.0.0 + */ +final class ServletContextCleaner { + + private static final Logger LOG = LoggerFactory.getLogger(ServletContextCleaner.class); + + private static final Set REMOVE_PREFIX = ImmutableSet.of( + "org.jboss.resteasy", + "resteasy", + "org.apache.shiro", + "sonia.scm" + ); + + private ServletContextCleaner() { + } + + /** + * Remove cached attributes from {@link ServletContext}. + * + * @param servletContext servlet context + */ + static void cleanup(ServletContext servletContext) { + LOG.info("remove cached attributes from context"); + + Enumeration attributeNames = servletContext.getAttributeNames(); + while( attributeNames.hasMoreElements()) { + String name = attributeNames.nextElement(); + if (shouldRemove(name)) { + LOG.info("remove attribute {} from servlet context", name); + servletContext.removeAttribute(name); + } else { + LOG.info("keep attribute {} in servlet context", name); + } + } + } + + private static boolean shouldRemove(String name) { + for (String prefix : REMOVE_PREFIX) { + if (name.startsWith(prefix)) { + return true; + } + } + return false; + } +} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/DefaultUberWebResourceLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultUberWebResourceLoader.java index 115a63fc2f..25b8390e53 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/DefaultUberWebResourceLoader.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultUberWebResourceLoader.java @@ -41,6 +41,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import sonia.scm.SCMContext; +import sonia.scm.Stage; import javax.servlet.ServletContext; import java.net.MalformedURLException; @@ -69,19 +71,21 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader //~--- constructors --------------------------------------------------------- - /** - * Constructs ... - * - * - * @param servletContext - * @param plugins - */ - public DefaultUberWebResourceLoader(ServletContext servletContext, - Iterable plugins) - { + public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable plugins) { + this(servletContext, plugins, SCMContext.getContext().getStage()); + } + + public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable plugins, Stage stage) { this.servletContext = servletContext; this.plugins = plugins; - this.cache = CacheBuilder.newBuilder().build(); + this.cache = createCache(stage); + } + + private Cache createCache(Stage stage) { + if (stage == Stage.DEVELOPMENT) { + return CacheBuilder.newBuilder().maximumSize(0).build(); // Disable caching + } + return CacheBuilder.newBuilder().build(); } //~--- get methods ---------------------------------------------------------- @@ -97,7 +101,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader @Override public URL getResource(String path) { - URL resource = cache.getIfPresent(path); + URL resource = getFromCache(path); if (resource == null) { @@ -105,7 +109,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader if (resource != null) { - cache.put(path, resource); + addToCache(path, resource); } } else @@ -116,6 +120,14 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader return resource; } + private URL getFromCache(String path) { + return cache.getIfPresent(path); + } + + private void addToCache(String path, URL url) { + cache.put(path, url); + } + /** * Method description * diff --git a/scm-webapp/src/main/resources/logback.default.xml b/scm-webapp/src/main/resources/logback.default.xml index 33e914d04d..b12b9e0890 100644 --- a/scm-webapp/src/main/resources/logback.default.xml +++ b/scm-webapp/src/main/resources/logback.default.xml @@ -65,9 +65,6 @@ - - - @@ -93,7 +90,9 @@ --> - + + + diff --git a/scm-webapp/src/main/webapp/WEB-INF/web.xml b/scm-webapp/src/main/webapp/WEB-INF/web.xml index 8abba66aa3..e69eb9fb2a 100644 --- a/scm-webapp/src/main/webapp/WEB-INF/web.xml +++ b/scm-webapp/src/main/webapp/WEB-INF/web.xml @@ -41,10 +41,6 @@ - - sonia.scm.boot.BootstrapContextListener - - BootstrapFilter sonia.scm.boot.BootstrapContextFilter @@ -55,25 +51,6 @@ /* - - - - resteasy.servlet.mapping.prefix - /api - - - - Resteasy - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - - - Resteasy - /api/* - -