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 CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.22.1/config/assets/logo.svg) Appsemble Create
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.22.2/config/assets/logo.svg) Appsemble Create
2
2
 
3
3
  > Bootstrap an Appsemble project
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/create-appsemble)](https://www.npmjs.com/package/create-appsemble)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.22.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.22.1)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.22.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.22.2)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -13,18 +13,19 @@
13
13
 
14
14
  ## Usage
15
15
 
16
- In a future release, this package lets a developer bootstrap Appsemble related boilerplate using
17
- `npm init` or `yarn create`.
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
- npm init appsemble
21
+ yarn create appsemble
21
22
  ```
22
23
 
23
24
  ```sh
24
- yarn create appsemble
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.1/LICENSE.md) ©
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 { configureLogger, handleError, version } from '@appsemble/node-utils';
3
- import yargs from 'yargs';
4
- yargs()
5
- .version(version)
6
- .option('verbose', {
7
- alias: 'v',
8
- describe: 'Increase verbosity',
9
- type: 'count',
10
- })
11
- .option('quiet', {
12
- alias: 'q',
13
- describe: 'Decrease verbosity',
14
- type: 'count',
15
- })
16
- .middleware([configureLogger])
17
- .demandCommand(1)
18
- .fail(handleError)
19
- .help()
20
- .completion()
21
- .parse(process.argv.slice(2));
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.1",
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.1",
43
- "@appsemble/types": "0.22.1",
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"
@@ -0,0 +1,3 @@
1
+ <!--- 'You can use this file to give users and contributors an overview of the organization.'
2
+ 'For more information please check `https://gitlab.com/appsemble/apps/template`.'
3
+ -->