Skip to content

Commit 3b8a945

Browse files
committed
refactor: rename to nuxt-extend
1 parent ecd83d7 commit 3b8a945

File tree

6 files changed

+460
-470
lines changed

6 files changed

+460
-470
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5-
### [0.0.2](https://github.com/nuxt/theme/compare/v0.0.1...v0.0.2) (2020-11-18)
5+
### [0.0.2](https://github.com/nuxt-community/nuxt-extend/compare/v0.0.1...v0.0.2) (2020-11-18)
66

77
### 0.0.1 (2020-11-12)
88

99

1010
### Features
1111

12-
* components level ([41071f1](https://github.com/nuxt/theme/commit/41071f1ef8e9e627e0f40e5ddc32eecc596f691d))
13-
* improvements ([3d13c4f](https://github.com/nuxt/theme/commit/3d13c4f82ed5b92f438b82cf778706491b42e0ec))
12+
* components level ([41071f1](https://github.com/nuxt-community/nuxt-extend/commit/41071f1ef8e9e627e0f40e5ddc32eecc596f691d))
13+
* improvements ([3d13c4f](https://github.com/nuxt-community/nuxt-extend/commit/3d13c4f82ed5b92f438b82cf778706491b42e0ec))

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# `@nuxt/theme`
1+
# `nuxt-extend`
22

33
[![npm version][npm-v-src]][npm-v-href]
44
[![npm downloads][npm-d-src]][npm-d-href]
55
[![ci][ci-src]][ci-href]
66

7-
Add theme/extends support to Nuxt 2 projects!
7+
Add config extending support to Nuxt 2 projects!
88

99
## Features
1010

11-
- Forward compatible with Nuxt 3 multi Apps
1211
- Support nested `extends`
1312
- Smartly merge config and hooks
1413
- Allow theme development to be like a normal nuxt project
@@ -17,44 +16,44 @@ Add theme/extends support to Nuxt 2 projects!
1716

1817
### Common Setup
1918

20-
Install `@nuxt/theme` as a dependency:
19+
Install `nuxt-extend` as a dependency:
2120

2221
```sh
2322
# yarn
24-
yarn add @nuxt/theme
23+
yarn add nuxt-extend
2524

2625
# npm
27-
npm i @nuxt/theme
26+
npm i nuxt-extend
2827
```
2928

3029
Update `nuxt.config` file:
3130

3231
```js
33-
import { resolveConfig } from '@nuxt/theme'
32+
import { resolveConfig } from 'nuxt-extend'
3433

3534
export default resolveConfig({
3635
// Your actual Nuxt configuration
3736
})
3837
```
3938

40-
### Theme Consumer
39+
### Parent
4140

4241
Use `extends` key in `nuxt.config`:
4342

4443
```js
45-
import { resolveConfig } from '@nuxt/theme'
44+
import { resolveConfig } from 'nuxt-extend'
4645

4746
export default resolveConfig({
4847
extends: '@nuxt/docs-theme',
4948
})
5049
```
5150

52-
### Theme Author
51+
### Child
5352

5453
1. Update `nuxt.config` and ensure required `rootDir` and `name` properties are provided
5554

5655
```js
57-
import { resolveConfig } from '@nuxt/theme'
56+
import { resolveConfig } from 'nuxt-extend'
5857

5958
export default resolveConfig({
6059
rootDir: __dirname,
@@ -71,11 +70,11 @@ export default resolveConfig({
7170
MIT. Made with 💖
7271
7372
<!-- Refs -->
74-
[npm-v-src]: https://img.shields.io/npm/v/@nuxt/theme?style=flat-square
75-
[npm-v-href]: https://npmjs.com/package/@nuxt/theme
73+
[npm-v-src]: https://img.shields.io/npm/v/nuxt-extend?style=flat-square
74+
[npm-v-href]: https://npmjs.com/package/nuxt-extend
7675
77-
[npm-d-src]: https://img.shields.io/npm/dm/@nuxt/theme?style=flat-square
78-
[npm-d-href]: https://npmjs.com/package/@nuxt/theme
76+
[npm-d-src]: https://img.shields.io/npm/dm/nuxt-extend?style=flat-square
77+
[npm-d-href]: https://npmjs.com/package/nuxt-extend
7978
80-
[ci-src]: https://img.shields.io/github/workflow/status/nuxt/theme/ci/master?style=flat-square
81-
[ci-href]: https://github.com/nuxt/theme/actions?query=workflow%3Aci
79+
[ci-src]: https://img.shields.io/github/workflow/status/nuxt-community/nuxt-extend/ci/master?style=flat-square
80+
[ci-href]: https://github.com/nuxt-community/nuxt-extend/actions?query=workflow%3Aci

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@nuxt/theme",
2+
"name": "nuxt-extend",
33
"version": "0.0.2",
44
"description": "",
5-
"repository": "nuxt/theme",
5+
"repository": "nuxt-community/nuxt-extend",
66
"license": "MIT",
77
"main": "./dist/index.js",
88
"types": "./dist/index.d.ts",
@@ -23,16 +23,16 @@
2323
"jiti": "^0.1.12"
2424
},
2525
"devDependencies": {
26-
"@nuxt/components": "^1.1.1",
27-
"@nuxt/types": "^2.14.7",
28-
"@nuxt/typescript-runtime": "^2.0.0",
26+
"@nuxt/components": "latest",
27+
"@nuxt/types": "latest",
28+
"@nuxt/typescript-runtime": "latest",
2929
"@nuxtjs/eslint-config-typescript": "latest",
3030
"@types/jest": "latest",
3131
"@types/node": "latest",
3232
"eslint": "latest",
3333
"jest": "latest",
34-
"nuxt": "^2.14.7",
35-
"siroc": "^0.4.1",
34+
"nuxt": "latest",
35+
"siroc": "latest",
3636
"standard-version": "latest",
3737
"ts-jest": "latest",
3838
"typescript": "latest"

src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { dirname } from 'path'
22
import Hookable, { configHooksT } from 'hookable'
33
import defu from 'defu'
4+
import jiti from 'jiti'
45
import type { NuxtConfig } from '@nuxt/types'
56

67
declare module '@nuxt/types' {
@@ -15,9 +16,9 @@ declare module '@nuxt/types' {
1516

1617
export function resolveConfig (config: string | NuxtConfig, from: string = process.cwd(), level = 0): NuxtConfig {
1718
if (typeof config === 'string') {
18-
const jiti = require('jiti')(from)
19-
const nuxtConfigFile = jiti.resolve(config)
20-
config = jiti(nuxtConfigFile) as NuxtConfig
19+
const _require = jiti(from)
20+
const nuxtConfigFile = _require.resolve(config)
21+
config = _require(nuxtConfigFile) as NuxtConfig
2122
config._file = nuxtConfigFile
2223

2324
if (!config.rootDir) {
@@ -26,7 +27,7 @@ export function resolveConfig (config: string | NuxtConfig, from: string = proce
2627
}
2728

2829
if (typeof config === 'function') {
29-
throw new TypeError('@nuxt/theme does not support Nuxt config as function')
30+
throw new TypeError('extending is not possible with nuxt config as a function')
3031
}
3132
if (!config.rootDir) {
3233
config.rootDir = from
@@ -48,18 +49,18 @@ export function resolveConfig (config: string | NuxtConfig, from: string = proce
4849
export function extendConfig (target: NuxtConfig, base: NuxtConfig): NuxtConfig {
4950
// Ensure base has required fields
5051
if (!base.name) {
51-
throw new Error('Theme config is missing the `name` property' + (base._file ? `in ${base._file}` : ''))
52+
throw new Error('Config is missing the `name` property' + (base._file ? `in ${base._file}` : ''))
5253
}
5354
if (!base.rootDir) {
54-
throw new Error('Theme config is missing the `rootDir` property')
55+
throw new Error('Config is missing the `rootDir` property')
5556
}
5657
if (!base.srcDir) {
5758
base.srcDir = base.rootDir
5859
}
5960

6061
// Ensure there is no name conflict
6162
if (target.alias && target.alias['~' + base.name]) {
62-
throw new Error('Theme name conflict: ' + base.name)
63+
throw new Error('Name conflict: ' + base.name)
6364
}
6465

6566
// Assign aliases for base

test/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const scrub = (input) => {
2424

2525
it('fails on config being a function', () => {
2626
const config = () => ({})
27-
expect(() => resolveConfig(config)).toThrow('@nuxt/theme does not support Nuxt config as function')
27+
expect(() => resolveConfig(config))
28+
.toThrow('extending is not possible with nuxt config as a function')
2829
})
2930

3031
it('matches snapshot', () => {

0 commit comments

Comments
 (0)