Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears committed Sep 3, 2023
1 parent e7bf5d4 commit 9895ae9
Show file tree
Hide file tree
Showing 50 changed files with 830 additions and 754 deletions.
25 changes: 24 additions & 1 deletion config/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
`plugin:react/recommended`,
`plugin:n/recommended-module`,
`plugin:perfectionist/recommended-alphabetical`,
`plugin:sort-class-members/recommended`,
],
ignorePatterns: [
`**/*.d.ts`,
Expand Down Expand Up @@ -54,6 +55,7 @@ module.exports = {
`react-hooks`,
`eslint-plugin-n`,
`perfectionist`,
`sort-class-members`,
],
rules: {
[`@typescript-eslint/explicit-member-accessibility`]: ERROR,
Expand Down Expand Up @@ -109,6 +111,7 @@ module.exports = {
[`n/shebang`]: OFF,
[`no-console`]: ERROR,
[`no-extra-semi`]: OFF,
[`perfectionist/sort-classes`]: OFF,
[`perfectionist/sort-imports`]: [
ERROR,
{
Expand All @@ -133,13 +136,33 @@ module.exports = {
`unknown`,
],
order: `asc`,
type: `alphabetical`,
type: `natural`,
},
],
[`react-hooks/exhaustive-deps`]: WARN,
[`react-hooks/rules-of-hooks`]: ERROR,
[`react/prop-types`]: OFF,
[`react/react-in-jsx-scope`]: OFF,
[`sort-class-members/sort-class-members`]: [
ERROR,
{
accessorPairPositioning: `getThenSet`,
groups: {
[`event-handlers`]: [{name: `/on.+/`, type: `method`}],
},
order: [
`[static-properties]`,
`[static-methods]`,
`[conventional-private-properties]`,
`[properties]`,
`[accessor-pairs]`,
`constructor`,
`[event-handlers]`,
`[methods]`,
`[conventional-private-methods]`,
],
},
],
},
settings: {
n: {
Expand Down
2 changes: 1 addition & 1 deletion config/vitest/config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {env} from 'node:process'

import GithubActionsReporter from 'vitest-github-actions-reporter'
import {defineConfig} from 'vitest/config'
import GithubActionsReporter from 'vitest-github-actions-reporter'

import alias from './alias.js'

Expand Down
2 changes: 1 addition & 1 deletion config/vitest/config.integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {env} from 'node:process'

import GithubActionsReporter from 'vitest-github-actions-reporter'
import {defineConfig} from 'vitest/config'
import GithubActionsReporter from 'vitest-github-actions-reporter'

import alias from './alias.js'

Expand Down
2 changes: 1 addition & 1 deletion config/vitest/config.unit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {env} from 'process'

import GithubActionsReporter from 'vitest-github-actions-reporter'
import {defineConfig} from 'vitest/config'
import GithubActionsReporter from 'vitest-github-actions-reporter'

import alias from './alias.js'

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@
},
"resolutions": {
"@yarnpkg/[email protected]": "patch:@yarnpkg/builder@npm%3A4.0.0-rc.49#./.yarn/patches/@yarnpkg-builder-npm-4.0.0-rc.49-3bed67fd94.patch"
},
"devDependencies": {
"eslint-plugin-sort-class-members": "1.18.0"
}
}
2 changes: 1 addition & 1 deletion sources/@repo/docs/src/theme/BlogTagsPostsPage/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Link from '@docusaurus/Link'
import {translate} from '@docusaurus/Translate'
import {
HtmlClassNameProvider,
PageMetadata,
ThemeClassNames,
usePluralForm,
} from '@docusaurus/theme-common'
import {translate} from '@docusaurus/Translate'
import {Hero} from '@site/src/components/hero'
import BlogPostItems from '@theme/BlogPostItems'
import Layout from '@theme/Layout'
Expand Down
118 changes: 57 additions & 61 deletions sources/@roots/bud-cache/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export default class Cache extends Service implements BudCache {
* {@link BudCache.enabled}
*/
public declare enabled: boolean
public set allowCollectingMemory(
value: Callback<FileCacheOptions[`allowCollectingMemory`]>,
) {
this.app.hooks.on(`build.cache.allowCollectingMemory`, value)
}

/**
* {@link BudCache.allowCollectingMemory}
*/
Expand All @@ -41,15 +35,10 @@ export default class Cache extends Service implements BudCache {
)
return typeof value === `boolean` ? value : fallback
}

/**
* {@link Service.boot}
*/
public override async boot?(bud: Bud) {
if (bud.context.force === true) {
await this.flush()
}
this.enabled = bud.context.cache !== false
public set allowCollectingMemory(
value: Callback<FileCacheOptions[`allowCollectingMemory`]>,
) {
this.app.hooks.on(`build.cache.allowCollectingMemory`, value)
}

/**
Expand Down Expand Up @@ -89,13 +78,65 @@ export default class Cache extends Service implements BudCache {
fallback
)
}

public set cacheDirectory(
directory: Callback<FileCacheOptions[`cacheDirectory`]>,
) {
this.app.hooks.on(`build.cache.cacheDirectory`, directory)
}

/**
* {@link BudCache.name}
*/
public get name(): string {
const fallback = join(
this.app.mode,
...Object.values(this.app.context._ ?? {}),
)
return (
this.app.hooks.filter(
`build.cache.name`,
this.app.hooks.filter(`build.name`, fallback),
) ?? fallback
)
}
public set name(name: string) {
this.app.hooks.on(`build.cache.name`, name)
}

/**
* {@link BudCache.type}
*/
public get type(): 'filesystem' | 'memory' {
const fallback = isString(this.app.context.cache)
? this.app.context.cache
: `filesystem`

return this.app.hooks.filter(`build.cache.type`) ?? fallback
}
public set type(type: Callback<FileCacheOptions[`type`]>) {
this.app.hooks.on(`build.cache.type`, type)
}

/**
* {@link BudCache.version}
*/
public get version(): string | undefined {
return this.app.hooks.filter(`build.cache.version`, undefined)
}
public set version(version: string) {
this.app.hooks.on(`build.cache.version`, version)
}

/**
* {@link Service.boot}
*/
public override async boot?(bud: Bud) {
if (bud.context.force === true) {
await this.flush()
}
this.enabled = bud.context.cache !== false
}

/**
* {@link BudCache.configuration}
* @readonly
Expand Down Expand Up @@ -153,26 +194,6 @@ export default class Cache extends Service implements BudCache {
return this.type
}

/**
* {@link BudCache.name}
*/
public get name(): string {
const fallback = join(
this.app.mode,
...Object.values(this.app.context._ ?? {}),
)
return (
this.app.hooks.filter(
`build.cache.name`,
this.app.hooks.filter(`build.name`, fallback),
) ?? fallback
)
}

public set name(name: string) {
this.app.hooks.on(`build.cache.name`, name)
}

/**
* {@link BudCache.register}
*/
Expand Down Expand Up @@ -221,29 +242,4 @@ export default class Cache extends Service implements BudCache {
this.type = type
return this
}

public set type(type: Callback<FileCacheOptions[`type`]>) {
this.app.hooks.on(`build.cache.type`, type)
}

/**
* {@link BudCache.type}
*/
public get type(): 'filesystem' | 'memory' {
const fallback = isString(this.app.context.cache)
? this.app.context.cache
: `filesystem`

return this.app.hooks.filter(`build.cache.type`) ?? fallback
}

public set version(version: string) {
this.app.hooks.on(`build.cache.version`, version)
}
/**
* {@link BudCache.version}
*/
public get version(): string | undefined {
return this.app.hooks.filter(`build.cache.version`, undefined)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {pulse} from './indicator.pulse.js'
* Indicator web component
*/
export class Component extends HTMLElement {
public static get observedAttributes() {
return [`has-errors`, `has-warnings`, `action`]
}
/**
* Status indicator colors
*/
Expand Down Expand Up @@ -37,51 +40,6 @@ export class Component extends HTMLElement {
this.renderShadow()
}

public static get observedAttributes() {
return [`has-errors`, `has-warnings`, `action`]
}

public attributeChangedCallback() {
if (this.hasAttribute(`has-errors`)) return this.onError()
if (this.hasAttribute(`has-warnings`)) return this.onWarning()

if (
!this.hasAttribute(`has-errors`) &&
!this.hasAttribute(`has-warnings`) &&
this.getAttribute(`action`) === `built`
)
return this.onSuccess()

if (
this.getAttribute(`action`) == `building` ||
this.getAttribute(`action`) == `sync`
)
return this.onPending()
}

/**
* Get accessor: has errors
*/
public get hasErrors(): boolean {
return this.getAttribute(`has-errors`) == `true`
}

/**
* Get accessor: has warnings
*/
public get hasWarnings(): boolean {
return this.getAttribute(`has-warnings`) == `true`
}

/**
* Hide status indicator
*/
public hide() {
this.hideTimeout = setTimeout(() => {
this.shadowRoot.querySelector(this.selector).classList.remove(`show`)
}, 2000)
}

/**
* Status is error
*/
Expand All @@ -93,7 +51,6 @@ export class Component extends HTMLElement {
.classList.remove(`warning`, `success`, `pending`)
this.shadowRoot.querySelector(this.selector).classList.add(`error`)
}

/**
* Status is pending
*/
Expand All @@ -108,7 +65,6 @@ export class Component extends HTMLElement {

this.hide()
}

/**
* Status is success
*/
Expand All @@ -123,7 +79,6 @@ export class Component extends HTMLElement {

this.hide()
}

/**
* Status is warning
*/
Expand All @@ -136,6 +91,46 @@ export class Component extends HTMLElement {

this.shadowRoot.querySelector(this.selector).classList.add(`warning`)
}
public attributeChangedCallback() {
if (this.hasAttribute(`has-errors`)) return this.onError()
if (this.hasAttribute(`has-warnings`)) return this.onWarning()

if (
!this.hasAttribute(`has-errors`) &&
!this.hasAttribute(`has-warnings`) &&
this.getAttribute(`action`) === `built`
)
return this.onSuccess()

if (
this.getAttribute(`action`) == `building` ||
this.getAttribute(`action`) == `sync`
)
return this.onPending()
}

/**
* Get accessor: has errors
*/
public get hasErrors(): boolean {
return this.getAttribute(`has-errors`) == `true`
}

/**
* Get accessor: has warnings
*/
public get hasWarnings(): boolean {
return this.getAttribute(`has-warnings`) == `true`
}

/**
* Hide status indicator
*/
public hide() {
this.hideTimeout = setTimeout(() => {
this.shadowRoot.querySelector(this.selector).classList.remove(`show`)
}, 2000)
}

/**
* Render status indicator
Expand Down
Loading

0 comments on commit 9895ae9

Please sign in to comment.