Skip to content

Commit

Permalink
Deprecate: @techor/one-linear
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Oct 31, 2023
1 parent aba5e25 commit 6c90fc5
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 375 deletions.
3 changes: 1 addition & 2 deletions packages/explore-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"name": "explore-config",
"scripts": {
"build:cjs": "esbuild src/index.ts --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node",
"build:esm": "esbuild src/index.ts --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node",
"build:type": "tsc --emitDeclarationOnly --preserveWatchOutput",
"build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:type",
"build": "pnpm run build:cjs && pnpm run build:type",
"dev": "pnpm run \"/^build:.*/\" --watch",
"test": "jest",
"type-check": "tsc --noEmit",
Expand Down
48 changes: 0 additions & 48 deletions packages/explore-config/src/core.ts

This file was deleted.

50 changes: 48 additions & 2 deletions packages/explore-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
export * from './core'
export { default as default } from './core'
import path from 'path'
import log from '@techor/log'
import extend from '@techor/extend'
import { explorePathSync } from '@techor/glob'
import crossImport from 'cross-import'

export default function exploreConfig(
source: string | string[],
options?: {
cwd?: string,
keys?: string[],
on?: {
found?: (foundPath: string) => void,
notFound?: () => void
}
}
) {
options = extend({
keys: ['config', 'default'],
on: {
found: (foundPath: string) => log.ok`**${foundPath}** config file found`,
notFound: () => log.i`No **${source}** config file found`
}
}, options)
const { on, keys } = options
let foundConfig: any
try {
const foundPath = explorePathSync(source, options)
if (foundPath) {
const foundConfigModule = crossImport(path.resolve(options.cwd || '', foundPath))
for (const key of keys) {
foundConfig = foundConfigModule[key]
if (foundConfig) {
break
}
}
if (!foundConfig) {
foundConfig = foundConfigModule
}
on.found?.(foundPath)
} else {
on.notFound?.()
}
} catch (err) {
log.error(err)
}
return foundConfig
}
2 changes: 1 addition & 1 deletion packages/explore-config/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import exploreConfig from '../src/core'
import exploreConfig from '../src'

it('read .js config', () => {
const config = exploreConfig('master.css.js', { cwd: __dirname })
Expand Down
2 changes: 1 addition & 1 deletion packages/log/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Object.assign(log, {
export { log }

export interface Log {
(strings: TemplateStringsArray | Error, ...messages: any[]): void
(strings: TemplateStringsArray | Error | string, ...messages: any[]): void
conflict: Log,
pass: Log,
e: Log, error: Log,
Expand Down
2 changes: 1 addition & 1 deletion packages/log/src/process-log.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk'
import { paint } from './paint'

export default function processLog(strings: TemplateStringsArray, slots: any[]) {
export default function processLog(strings: TemplateStringsArray | string, slots: any[]) {
let message = ''
if (Array.isArray(strings)) {
for (let i = 0; i < strings.length; i++) {
Expand Down
127 changes: 0 additions & 127 deletions packages/one-liner/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions packages/one-liner/jest.config.ts

This file was deleted.

57 changes: 0 additions & 57 deletions packages/one-liner/package.json

This file was deleted.

49 changes: 0 additions & 49 deletions packages/one-liner/src/index.ts

This file was deleted.

Loading

0 comments on commit 6c90fc5

Please sign in to comment.