create-appsemble 0.22.1 → 0.22.2
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 +8 -7
- package/index.d.ts +1 -1
- package/index.js +50 -20
- package/package.json +4 -5
- package/templates/gitlab/README.md +3 -0
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Create
|
|
2
2
|
|
|
3
3
|
> Bootstrap an Appsemble project
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-appsemble)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.22.2)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
`
|
|
16
|
+
This package allows you to bootstrap an Appsemble project repository structure using `npm init` or
|
|
17
|
+
`yarn create`. The initial command will be followed by a number of interactive questions. Run the
|
|
18
|
+
following command with the package manager of your choice to scaffold a new project.
|
|
18
19
|
|
|
19
20
|
```sh
|
|
20
|
-
|
|
21
|
+
yarn create appsemble
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
```sh
|
|
24
|
-
|
|
25
|
+
npm init appsemble
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
## License
|
|
28
29
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.22.
|
|
30
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.22.2/LICENSE.md) ©
|
|
30
31
|
[Appsemble](https://appsemble.com)
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export declare function handler(): Promise<void>;
|
package/index.js
CHANGED
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import { cp, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { logger, readData, writeData } from '@appsemble/node-utils';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
const templatesDir = new URL('templates/', import.meta.url);
|
|
7
|
+
function validateProjectName(input) {
|
|
8
|
+
if (input.length > 30 || input.length === 0) {
|
|
9
|
+
logger.error('Please input a valid project name. Name must be between 1 and 30 characters long.');
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
export async function handler() {
|
|
15
|
+
const answers = await inquirer.prompt([
|
|
16
|
+
{
|
|
17
|
+
name: 'name',
|
|
18
|
+
message: 'Please enter the name of your project.',
|
|
19
|
+
validate: validateProjectName,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'path',
|
|
23
|
+
message: 'Please enter the path for where you want the project folder to go (default ".").',
|
|
24
|
+
},
|
|
25
|
+
].filter(Boolean));
|
|
26
|
+
const { name } = answers;
|
|
27
|
+
const path = answers.path || process.cwd();
|
|
28
|
+
const outputDirectory = join(path, name);
|
|
29
|
+
const inputDirectory = new URL('gitlab/', templatesDir);
|
|
30
|
+
const pkgPath = new URL('package.json', inputDirectory);
|
|
31
|
+
const [inputPkg] = await readData(pkgPath);
|
|
32
|
+
const outputPkg = {
|
|
33
|
+
name,
|
|
34
|
+
...inputPkg,
|
|
35
|
+
};
|
|
36
|
+
const readmePath = new URL('README.md', inputDirectory);
|
|
37
|
+
const inputReadme = await readFile(readmePath, 'utf8');
|
|
38
|
+
const inputReadmeArray = inputReadme.split('\n');
|
|
39
|
+
const outputReadmeArray = [`# ${name}`, ...inputReadmeArray];
|
|
40
|
+
const outputReadme = outputReadmeArray.join('\n');
|
|
41
|
+
await cp(inputDirectory, outputDirectory, {
|
|
42
|
+
errorOnExist: true,
|
|
43
|
+
filter: (src) => !src.endsWith('package.json') || !src.endsWith('README.md'),
|
|
44
|
+
force: false,
|
|
45
|
+
recursive: true,
|
|
46
|
+
});
|
|
47
|
+
await writeData(join(outputDirectory, 'package.json'), outputPkg);
|
|
48
|
+
await writeFile(join(outputDirectory, 'README.md'), outputReadme);
|
|
49
|
+
logger.info(`Successfully created ${name} at ${outputDirectory}`);
|
|
50
|
+
}
|
|
51
|
+
await handler();
|
|
22
52
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-appsemble",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "Bootstrap an Appsemble project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -39,12 +39,11 @@
|
|
|
39
39
|
"test": "vitest"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@appsemble/node-utils": "0.22.
|
|
43
|
-
"@appsemble/types": "0.22.
|
|
42
|
+
"@appsemble/node-utils": "0.22.2",
|
|
43
|
+
"@appsemble/types": "0.22.2",
|
|
44
44
|
"inquirer": "^9.0.0",
|
|
45
45
|
"type-fest": "^4.0.0",
|
|
46
|
-
"yaml": "^2.0.0"
|
|
47
|
-
"yargs": "^17.0.0"
|
|
46
|
+
"yaml": "^2.0.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@types/inquirer": "^9.0.0"
|