nsbp-cli 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/templates/basic/config/webpack.base.js +15 -1
- package/templates/basic/gitignore +0 -3
- package/templates/basic/src/Routers.tsx +5 -5
- package/templates/basic/src/client/index.tsx +5 -5
- package/templates/basic/src/component/Header.tsx +1 -1
- package/templates/basic/src/component/Layout.tsx +1 -1
- package/templates/basic/src/component/Theme.tsx +1 -1
- package/templates/basic/src/containers/Home.tsx +1 -1
- package/templates/basic/src/containers/Login.tsx +3 -3
- package/templates/basic/src/containers/Photo.tsx +9 -9
- package/templates/basic/src/reducers/home.ts +1 -1
- package/templates/basic/src/reducers/index.ts +1 -1
- package/templates/basic/src/reducers/photo.ts +2 -2
- package/templates/basic/src/server/index.ts +3 -3
- package/templates/basic/src/server/utils.tsx +4 -8
- package/templates/basic/src/services/home.ts +2 -27
- package/templates/basic/src/services/photo.ts +4 -4
- package/templates/basic/src/store/index.ts +1 -1
- package/templates/basic/tsconfig.json +21 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ node ./bin/nsbp.js --help # Test CLI locally
|
|
|
147
147
|
|
|
148
148
|
- **Package Name**: `nsbp-cli`
|
|
149
149
|
- **Bin Command**: `nsbp` (install globally and run `nsbp --help`)
|
|
150
|
-
- **Version**: `0.2.
|
|
150
|
+
- **Version**: `0.2.27`
|
|
151
151
|
- **Dependencies**: chalk, commander, fs-extra, inquirer
|
|
152
152
|
- **Package Manager**: Uses pnpm (also compatible with npm)
|
|
153
153
|
- **Node Version**: >=16.0.0
|
package/package.json
CHANGED
|
@@ -17,7 +17,21 @@ module.exports = ({ mode, entry, server, init }) => {
|
|
|
17
17
|
entry,
|
|
18
18
|
devtool: 'source-map',
|
|
19
19
|
resolve: {
|
|
20
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
20
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
21
|
+
alias: {
|
|
22
|
+
'@': path.resolve(__dirname, '../src'),
|
|
23
|
+
'@components': path.resolve(__dirname, '../src/component'),
|
|
24
|
+
'@utils': path.resolve(__dirname, '../src/utils'),
|
|
25
|
+
'@services': path.resolve(__dirname, '../src/services'),
|
|
26
|
+
'@styled': path.resolve(__dirname, '../src/styled'),
|
|
27
|
+
'@store': path.resolve(__dirname, '../src/store'),
|
|
28
|
+
'@reducers': path.resolve(__dirname, '../src/reducers'),
|
|
29
|
+
'@containers': path.resolve(__dirname, '../src/containers'),
|
|
30
|
+
'@server': path.resolve(__dirname, '../src/server'),
|
|
31
|
+
'@client': path.resolve(__dirname, '../src/client'),
|
|
32
|
+
'@css': path.resolve(__dirname, '../src/css'),
|
|
33
|
+
'@externals': path.resolve(__dirname, '../src/externals')
|
|
34
|
+
}
|
|
21
35
|
},
|
|
22
36
|
module: {
|
|
23
37
|
rules: [
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { loadData as homeLoadData } from '
|
|
3
|
-
import { loadData as photoLoadData } from '
|
|
2
|
+
import { loadData as homeLoadData } from '@services/home'
|
|
3
|
+
import { loadData as photoLoadData } from '@services/photo'
|
|
4
4
|
import loadable from "@loadable/component"
|
|
5
5
|
|
|
6
6
|
const Loading = () => {
|
|
7
7
|
return <div>Loading...</div>
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const Home = loadable(() => import("
|
|
10
|
+
const Home = loadable(() => import("@containers/Home"), {
|
|
11
11
|
fallback: <Loading />
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
const Login = loadable(() => import("
|
|
14
|
+
const Login = loadable(() => import("@containers/Login"), {
|
|
15
15
|
fallback: <Loading />
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
const Photo = loadable(() => import("
|
|
18
|
+
const Photo = loadable(() => import("@containers/Photo"), {
|
|
19
19
|
fallback: <Loading />
|
|
20
20
|
})
|
|
21
21
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { hydrateRoot } from 'react-dom/client'
|
|
3
3
|
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
|
4
|
-
import routers from '
|
|
4
|
+
import routers from '@/Routers'
|
|
5
5
|
import { Provider } from 'react-redux'
|
|
6
|
-
import getStore from '
|
|
7
|
-
import { isSEO } from '
|
|
8
|
-
import Theme from '
|
|
6
|
+
import getStore from '@/store'
|
|
7
|
+
import { isSEO } from '@/utils'
|
|
8
|
+
import Theme from '@components/Theme'
|
|
9
9
|
import { loadableReady } from '@loadable/component'
|
|
10
10
|
|
|
11
11
|
const App = () => {
|
|
@@ -33,5 +33,5 @@ const App = () => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
loadableReady(() => {
|
|
36
|
-
|
|
36
|
+
hydrateRoot(document.getElementById('root')!, <App />)
|
|
37
37
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { Link, useLocation } from 'react-router-dom'
|
|
3
|
-
import { Container, LogoWrapper as Logo, Nav, NavLink, Brand } from '
|
|
3
|
+
import { Container, LogoWrapper as Logo, Nav, NavLink, Brand } from '@styled/component/header'
|
|
4
4
|
|
|
5
5
|
const Header = () => {
|
|
6
6
|
const location = useLocation()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { Fragment } from 'react'
|
|
2
|
-
import Header from '
|
|
3
|
-
import Layout from '
|
|
2
|
+
import Header from '@components/Header'
|
|
3
|
+
import Layout from '@components/Layout'
|
|
4
4
|
import { Helmet } from 'react-helmet'
|
|
5
5
|
import '../css/test.css'
|
|
6
6
|
import '../css/test.less'
|
|
7
7
|
import '../css/test2.sass'
|
|
8
8
|
import '../css/test3.scss'
|
|
9
|
-
import { Container } from '
|
|
9
|
+
import { Container } from '@styled/test'
|
|
10
10
|
|
|
11
11
|
const Login = ({ query }: any) => {
|
|
12
12
|
return (
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import React, { Fragment, useState, useEffect } from 'react'
|
|
2
2
|
import { connect } from 'react-redux'
|
|
3
3
|
import { Link, useLocation } from 'react-router-dom'
|
|
4
|
-
import Header from '
|
|
5
|
-
import Layout from '
|
|
4
|
+
import Header from '@components/Header'
|
|
5
|
+
import Layout from '@components/Layout'
|
|
6
6
|
import { Helmet } from 'react-helmet'
|
|
7
|
-
import { Container, Row } from '
|
|
7
|
+
import { Container, Row } from '@styled/photo'
|
|
8
8
|
import { motion } from 'framer-motion'
|
|
9
|
-
import { isSEO, getLocationParams } from '
|
|
10
|
-
import { useCurrentFlag } from '
|
|
9
|
+
import { isSEO, getLocationParams } from '@/utils'
|
|
10
|
+
import { useCurrentFlag } from '@utils/clientConfig'
|
|
11
11
|
import _ from 'lodash'
|
|
12
|
-
import { loadData } from '
|
|
12
|
+
import { loadData } from '@services/photo'
|
|
13
13
|
|
|
14
|
-
const springSettings = { type: "spring", stiffness: 170, damping: 26 }
|
|
14
|
+
const springSettings = { type: "spring" as const, stiffness: 170, damping: 26 }
|
|
15
15
|
const NEXT = 'show-next'
|
|
16
16
|
|
|
17
17
|
const Photo = ({ query, data, menu, getPhotoMenu }: any) => {
|
|
18
18
|
const location = useLocation()
|
|
19
|
-
let {
|
|
19
|
+
let { from } = query
|
|
20
20
|
const photos = Array.isArray(data) ? data : []
|
|
21
21
|
const [currPhoto, setCurrPhoto] = useState(0)
|
|
22
22
|
|
|
@@ -38,7 +38,7 @@ const Photo = ({ query, data, menu, getPhotoMenu }: any) => {
|
|
|
38
38
|
.reduce((sum:any, width:any) => sum - width, 0)
|
|
39
39
|
|
|
40
40
|
// Calculate position for each photo
|
|
41
|
-
const photoPositions = photos.reduce((acc:any, [
|
|
41
|
+
const photoPositions = photos.reduce((acc:any, [_origW, _origH]:any, i:any, _arr:any) => {
|
|
42
42
|
const prevLeft = i === 0 ? leftStartCoords : acc[i-1].left + acc[i-1].width
|
|
43
43
|
acc.push({
|
|
44
44
|
left: prevLeft,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { homeReducer } from './home'
|
|
2
2
|
import { photoReducer } from './photo'
|
|
3
|
-
import { REQUEST_QUERY } from '
|
|
3
|
+
import { REQUEST_QUERY } from '@store/constants'
|
|
4
4
|
|
|
5
5
|
const queryReducer = (state = {}, action: any) => {
|
|
6
6
|
const { type, query } = action
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { GET_PHOTO_MENU, GET_PHOTO_WIDTH_HEIGHT } from '
|
|
1
|
+
import { GET_PHOTO_MENU, GET_PHOTO_WIDTH_HEIGHT } from '@store/constants'
|
|
2
2
|
|
|
3
3
|
interface PhotoState {
|
|
4
4
|
data: [number, number, string][]
|
|
5
5
|
menu: Record<string, any> | Array<{ name: string; cover?: string; count?: number }>
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export const photoReducer = (state: PhotoState = { data: [[0, 0]], menu: {} }, action: any) => {
|
|
8
|
+
export const photoReducer = (state: PhotoState = { data: [[0, 0, '']], menu: {} }, action: any) => {
|
|
9
9
|
const { type, data, menu } = action
|
|
10
10
|
|
|
11
11
|
switch (type) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import express from 'express'
|
|
2
2
|
import helmet from 'helmet'
|
|
3
3
|
import rateLimit from 'express-rate-limit'
|
|
4
|
-
import { render } from '
|
|
5
|
-
import { getPhotoWH, getPhotoMenu } from '
|
|
6
|
-
import { useCurrentFlag, outPhotoDicPath } from '
|
|
4
|
+
import { render } from '@server/utils'
|
|
5
|
+
import { getPhotoWH, getPhotoMenu } from '@server/photo'
|
|
6
|
+
import { useCurrentFlag, outPhotoDicPath } from '@utils/config'
|
|
7
7
|
|
|
8
8
|
const app = express()
|
|
9
9
|
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { renderToString } from 'react-dom/server'
|
|
3
3
|
import { StaticRouter, Route, matchPath } from 'react-router-dom'
|
|
4
|
-
// @ts-ignore - Routes is available in react-router-dom v7 but not in types
|
|
5
4
|
import { Routes } from 'react-router-dom'
|
|
6
|
-
import routers from '
|
|
7
|
-
// @ts-ignore
|
|
5
|
+
import routers from '@/Routers'
|
|
8
6
|
import { Provider } from 'react-redux'
|
|
9
|
-
|
|
10
|
-
import getStore from '../store'
|
|
7
|
+
import getStore from '@store'
|
|
11
8
|
import serialize from 'serialize-javascript'
|
|
12
|
-
|
|
13
|
-
import { REQUEST_QUERY } from '../store/constants'
|
|
9
|
+
import { REQUEST_QUERY } from '@store/constants'
|
|
14
10
|
import { Helmet } from 'react-helmet'
|
|
15
11
|
import { ServerStyleSheet } from 'styled-components'
|
|
16
|
-
import Theme from '
|
|
12
|
+
import Theme from '@components/Theme'
|
|
17
13
|
import path from 'path'
|
|
18
14
|
import { ChunkExtractor } from '@loadable/server'
|
|
19
15
|
|
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
import { doGet } from '
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const getData = (callback: any) => {
|
|
5
|
-
|
|
6
|
-
return (dispatch: any) => {
|
|
7
|
-
doGet('https://api.apiopen.top/getJoke?page=1&count=2&type=video')
|
|
8
|
-
.then((res:any) => {
|
|
9
|
-
// console.log('res', res)
|
|
10
|
-
dispatch({
|
|
11
|
-
type: GITHUB_ZEITNEXT_GET,
|
|
12
|
-
data: res?.data
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
callback && callback()
|
|
16
|
-
})
|
|
17
|
-
.catch((e:any) => {
|
|
18
|
-
// console.log('e', e.response)
|
|
19
|
-
dispatch({
|
|
20
|
-
type: GITHUB_ZEITNEXT_GET,
|
|
21
|
-
data: e?.response?.data
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
callback && callback()
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { doGet } from '@utils/fetch'
|
|
2
|
+
import { GET_PHOTO_MENU } from '@store/constants'
|
|
28
3
|
|
|
29
4
|
export const loadData = (resolve: any = null) => {
|
|
30
5
|
return (dispatch: any) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { doGet } from '
|
|
2
|
-
import { GET_PHOTO_MENU, GET_PHOTO_WIDTH_HEIGHT } from '
|
|
1
|
+
import { doGet } from '@utils/fetch'
|
|
2
|
+
import { GET_PHOTO_MENU, GET_PHOTO_WIDTH_HEIGHT } from '@store/constants'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const getPhotoWH = (dispatch: any, callback: any, dic = '') => {
|
|
@@ -18,7 +18,7 @@ const getPhotoWH = (dispatch: any, callback: any, dic = '') => {
|
|
|
18
18
|
})
|
|
19
19
|
callback && callback()
|
|
20
20
|
})
|
|
21
|
-
.catch((
|
|
21
|
+
.catch((_e:any) => {
|
|
22
22
|
callback && callback()
|
|
23
23
|
})
|
|
24
24
|
}
|
|
@@ -36,7 +36,7 @@ const getPhotoMenu = (dispatch:any, callback:any) => {
|
|
|
36
36
|
|
|
37
37
|
callback && callback(data)
|
|
38
38
|
})
|
|
39
|
-
.catch((
|
|
39
|
+
.catch((_e:any) => {
|
|
40
40
|
callback && callback()
|
|
41
41
|
})
|
|
42
42
|
}
|
|
@@ -13,7 +13,27 @@
|
|
|
13
13
|
"allowSyntheticDefaultImports": true,
|
|
14
14
|
"esModuleInterop": true,
|
|
15
15
|
"preserveConstEnums": true,
|
|
16
|
-
"skipLibCheck": true
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"baseUrl": ".",
|
|
18
|
+
"paths": {
|
|
19
|
+
"@/*": ["./src/*"],
|
|
20
|
+
"@components/*": ["./src/component/*"],
|
|
21
|
+
"@utils/*": ["./src/utils/*"],
|
|
22
|
+
"@services/*": ["./src/services/*"],
|
|
23
|
+
"@styled/*": ["./src/styled/*"],
|
|
24
|
+
"@store/*": ["./src/store/*"],
|
|
25
|
+
"@reducers/*": ["./src/reducers/*"],
|
|
26
|
+
"@containers/*": ["./src/containers/*"],
|
|
27
|
+
"@server/*": ["./src/server/*"],
|
|
28
|
+
"@client/*": ["./src/client/*"],
|
|
29
|
+
"@css/*": ["./src/css/*"],
|
|
30
|
+
"@externals/*": ["./src/externals/*"],
|
|
31
|
+
"@reducers": ["./src/reducers/index"],
|
|
32
|
+
"@store": ["./src/store/index"],
|
|
33
|
+
"@utils": ["./src/utils/index"],
|
|
34
|
+
"@client": ["./src/client/index"],
|
|
35
|
+
"@server": ["./src/server/index"]
|
|
36
|
+
}
|
|
17
37
|
},
|
|
18
38
|
"include":[
|
|
19
39
|
"./src/**/*",
|