-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
2,053 additions
and
1,399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# alita | ||
|
||
See our website [alitajs](https://alitajs.com) for more information. | ||
See our website [alitajs](https://alitajs.com) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
{ | ||
"name": "alita", | ||
"version": "0.0.0-alpha.1", | ||
"version": "3.0.0-alpha.1", | ||
"description": "v3 develop version", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "index.esm.js", | ||
"bin": { | ||
"alita": "bin/alita.js" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
|
@@ -18,7 +14,7 @@ | |
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/alitajs/alita-next-step" | ||
"url": "https://github.com/alitajs/alita-next" | ||
}, | ||
"authors": [ | ||
"chenxiaocong <[email protected]> (https://github.com/xiaohuoni)" | ||
|
@@ -29,12 +25,15 @@ | |
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bin": { | ||
"alita": "bin/alita.js" | ||
}, | ||
"dependencies": { | ||
"@alita/plugins": "workspace:*", | ||
"@umijs/preset-umi": "4.0.0-beta.13", | ||
"@umijs/utils": "4.0.0-beta.13", | ||
"@umijs/core": "4.0.0-beta.13", | ||
"umi": "4.0.0-beta.13", | ||
"@umijs/preset-umi": "4.0.0-beta.15", | ||
"@umijs/utils": "4.0.0-beta.15", | ||
"@umijs/core": "4.0.0-beta.15", | ||
"umi": "4.0.0-beta.15", | ||
"v8-compile-cache": "^2.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @alita/create-alita | ||
|
||
See our website [alitajs](https://alitajs.com) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../dist/cli'); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@alita/create-alita", | ||
"version": "3.0.0-alpha.1", | ||
"description": "create-alita", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"templates" | ||
], | ||
"scripts": { | ||
"build": "pnpm tsc", | ||
"build:deps": "pnpm esno ../../scripts/bundleDeps.ts", | ||
"dev": "pnpm build -- --watch" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/alitajs/alita-next" | ||
}, | ||
"authors": [ | ||
"chenxiaocong <[email protected]> (https://github.com/xiaohuoni)" | ||
], | ||
"license": "MIT", | ||
"bugs": "https://github.com/alitajs/alita-next/issues", | ||
"homepage": "https://github.com/alitajs/alita-next/tree/master/packages/create-alita#readme", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bin": { | ||
"create-alita": "bin/create-alita.js" | ||
}, | ||
"dependencies": { | ||
"@umijs/utils": "4.0.0-beta.15" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { chalk, yParser } from '@umijs/utils'; | ||
import { existsSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const args = yParser(process.argv.slice(2), { | ||
alias: { | ||
version: ['v'], | ||
help: ['h'], | ||
}, | ||
boolean: ['version'], | ||
}); | ||
|
||
if (args.version && !args._[0]) { | ||
args._[0] = 'version'; | ||
const local = existsSync(join(__dirname, '../.local')) | ||
? chalk.cyan('@local') | ||
: ''; | ||
const { name, version } = require('../package.json'); | ||
console.log(`${name}@${version}${local}`); | ||
} else { | ||
require('./') | ||
.default({ | ||
cwd: process.cwd(), | ||
args, | ||
}) | ||
.catch((err: Error) => { | ||
console.error(`Create failed, ${err.message}`); | ||
console.error(err); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { rimraf } from '@umijs/utils'; | ||
import { existsSync } from 'fs'; | ||
import { join } from 'path'; | ||
import runGenerator from './index'; | ||
|
||
const fixtures = join(__dirname, '..', 'fixtures'); | ||
|
||
let oldCwd = process.cwd(); | ||
|
||
beforeEach(() => { | ||
oldCwd = process.cwd(); | ||
}); | ||
|
||
afterEach(() => { | ||
process.chdir(oldCwd); | ||
}); | ||
|
||
test('generate app', async () => { | ||
const cwd = join(fixtures, 'app'); | ||
await runGenerator({ | ||
cwd, | ||
args: { | ||
_: [], | ||
$0: '', | ||
default: true, | ||
}, | ||
}); | ||
expect(existsSync(join(cwd, 'pages', 'index.tsx'))).toEqual(true); | ||
rimraf.sync(cwd); | ||
}); | ||
|
||
test('generate plugin', async () => { | ||
const cwd = join(fixtures, 'plugin'); | ||
await runGenerator({ | ||
cwd, | ||
args: { | ||
plugin: true, | ||
_: [], | ||
$0: '', | ||
default: true, | ||
}, | ||
}); | ||
expect(existsSync(join(cwd, 'src', 'index.ts'))).toEqual(true); | ||
rimraf.sync(cwd); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { | ||
BaseGenerator, | ||
installWithNpmClient, | ||
prompts, | ||
yParser, | ||
} from '@umijs/utils'; | ||
import { join } from 'path'; | ||
|
||
const testData = { | ||
name: 'umi-plugin-demo', | ||
description: 'nothing', | ||
mail: '[email protected]', | ||
author: 'xiaohuoni', | ||
org: 'alitajs', | ||
version: require('../package').version, | ||
npmClient: 'pnpm', | ||
registry: 'https://registry.npmjs.org/', | ||
}; | ||
|
||
export default async ({ | ||
cwd, | ||
args, | ||
}: { | ||
cwd: string; | ||
args: yParser.Arguments; | ||
}) => { | ||
const [_, name] = args._; | ||
let npmClient = 'pnpm' as any; | ||
let registry = 'https://registry.npmjs.org/'; | ||
// test ignore prompts | ||
if (!args.default) { | ||
const response = await prompts([ | ||
{ | ||
type: 'select', | ||
name: 'npmClient', | ||
message: 'Pick Npm Client', | ||
choices: [ | ||
{ title: 'npm', value: 'npm' }, | ||
{ title: 'cnpm', value: 'cnpm' }, | ||
{ title: 'tnpm', value: 'tnpm' }, | ||
{ title: 'yarn', value: 'yarn' }, | ||
{ title: 'pnpm', value: 'pnpm', selected: true }, | ||
], | ||
}, | ||
{ | ||
type: 'select', | ||
name: 'registry', | ||
message: 'Pick Bpm Registry', | ||
choices: [ | ||
{ | ||
title: 'npm', | ||
value: 'https://registry.npmjs.org/', | ||
selected: true, | ||
}, | ||
{ title: 'taobao', value: 'https://registry.npmmirror.com' }, | ||
], | ||
}, | ||
]); | ||
npmClient = response.npmClient; | ||
registry = response.registry; | ||
} | ||
|
||
const pluginPrompts = [ | ||
{ | ||
name: 'name', | ||
type: 'text', | ||
message: `What's the plugin name?`, | ||
default: name, | ||
}, | ||
{ | ||
name: 'description', | ||
type: 'text', | ||
message: `What's your plugin used for?`, | ||
}, | ||
{ | ||
name: 'mail', | ||
type: 'text', | ||
message: `What's your email?`, | ||
}, | ||
{ | ||
name: 'author', | ||
type: 'text', | ||
message: `What's your name?`, | ||
}, | ||
{ | ||
name: 'org', | ||
type: 'text', | ||
message: `Which organization is your plugin stored under github?`, | ||
}, | ||
] as prompts.PromptObject[]; | ||
|
||
const generator = new BaseGenerator({ | ||
path: join(__dirname, '..', 'templates', args.plugin ? 'plugin' : 'app'), | ||
target: name ? join(cwd, name) : cwd, | ||
data: args.default | ||
? testData | ||
: { | ||
version: require('../package').version, | ||
npmClient, | ||
registry, | ||
}, | ||
questions: args.default ? [] : args.plugin ? pluginPrompts : [], | ||
}); | ||
await generator.run(); | ||
|
||
if (!args.default) { | ||
// install | ||
installWithNpmClient({ npmClient }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/node_modules | ||
/.env.local | ||
/.umirc.local.ts | ||
/.umirc.local.js | ||
/config/config.local.ts | ||
/config/config.local.js | ||
/src/.umi | ||
/.umi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry={{{ registry }}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
npmClient: '{{{ npmClient }}}' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { Link, Outlet } from 'umi'; | ||
|
||
export default function Layout() { | ||
return ( | ||
<div> | ||
<h2>global layout</h2> | ||
<ul> | ||
<li> | ||
<Link to="/">Home</Link> | ||
</li> | ||
<li> | ||
<Link to="/users">/users</Link> | ||
</li> | ||
<li> | ||
<Link to="/users/foo">/users/foo</Link> | ||
</li> | ||
</ul> | ||
<Outlet /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "alita dev", | ||
"build": "alita build", | ||
"postinstall": "alita setup", | ||
"start": "npm run dev" | ||
}, | ||
"dependencies": { | ||
"alita": "^{{{ version }}}" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"typescript": "^4.1.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export default function HomePage() { | ||
return <div>HomePage</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<h2>users layout</h2> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import React from 'react'; | ||
|
||
export default () => <h2>user: Foo</h2>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
target: 'node', | ||
cjs: { type: 'babel', lazy: true }, | ||
disableTypeCheck: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry={{{ registry }}} |
Oops, something went wrong.