Skip to content

Commit 9e96739

Browse files
authored
feat: Add command to create ELPA project (#94)
* feat: Add commandto create ELPA project * feat: Add commandto create ELPA project * changelog * Update documentation preparation * Correct syntax * docs
1 parent c487c7f commit 9e96739

File tree

15 files changed

+240
-78
lines changed

15 files changed

+240
-78
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
2929
* Fix keyword lint undetected (#88)
3030
* Improve Eask-file loader to search file upward (#89)
3131
* Move command `activate` under test subcommand (#92)
32+
* Add command to create ELPA project (#94)
3233

3334
## 0.7.x
3435
> Released Sep 08, 2022

Easkfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
(website-url "https://github.com/emacs-eask/cli")
66
(keywords "emacs" "package" "management" "cli")
77

8-
(script "test" "echo \"Error: no test specified\" && exit 1")
8+
(script "test" "echo \"Error: no test specified\" && exit 1")
9+
(script "install" "npm install")
10+
(script "setup-doc" "cd ./docs/themes/geekdoc/ && npm install && npm run build")
11+
(script "serve-doc" "cd ./docs/ && hugo server")
912

1013
(files
1114
"eask"

cmds/core/create.js

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,14 @@
1919

2020
"use strict";
2121

22-
const child_process = require('child_process');
23-
24-
const init = require('./init');
25-
26-
exports.command = ['create <name>', 'new <name>'];
22+
exports.command = ['create <type>'];
2723
exports.desc = 'Create a new elisp project';
28-
exports.builder = {
29-
name: {
30-
description: 'new project name',
31-
requiresArg: false,
32-
type: 'string',
33-
},
34-
};
35-
36-
const TEMPLATE_URL = 'https://github.com/emacs-eask/template-elisp';
24+
exports.builder = function (yargs) {
25+
return yargs
26+
.usage(`${exports.desc}
3727
38-
exports.handler = async (argv) => {
39-
const project_name = argv.name;
40-
41-
let proc = child_process.spawn('git', ['clone', TEMPLATE_URL, project_name],
42-
{ stdio: 'inherit' });
43-
44-
// You would just need to register the error event, or else it can't print
45-
// the help instruction below.
46-
proc.on('error', function () { });
47-
48-
proc.on('close', function (code) {
49-
if (code == 0) {
50-
console.log('✓ Done cloning the template project');
51-
console.log('');
52-
process.chdir(project_name);
53-
_cloned(argv);
54-
return;
55-
}
56-
// Help instruction here!
57-
console.log('✗ Error while cloning template project');
58-
console.log('');
59-
console.log(' [1] Make sure you have git installed and has the right permission');
60-
process.stdout.write(` [2] Failed because of the target directory isn't empty`);
61-
});
28+
Usage: eask create <command> [options..]`)
29+
.commandDir('../create/');
6230
};
6331

64-
65-
/* Operations after _cloned */
66-
async function _cloned(argv) {
67-
console.log('Initialize the Eask-file for your project...');
68-
await init.create_eask_file();
69-
UTIL.e_call(argv, 'core/create');
70-
}
32+
exports.handler = async (argv) => { };

cmds/create/elpa.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (C) 2023 Jen-Chieh Shen
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with GNU Emacs; see the file COPYING. If not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
"use strict";
21+
22+
const child_process = require('child_process');
23+
24+
const init = require('../core/init');
25+
26+
exports.command = ['elpa <name>'];
27+
exports.desc = 'Create a new ELPA using github-elpa';
28+
exports.builder = {
29+
name: {
30+
description: 'new ELPA name',
31+
requiresArg: false,
32+
type: 'string',
33+
},
34+
};
35+
36+
const TEMPLATE_URL = 'https://github.com/emacs-eask/template-elpa';
37+
38+
exports.handler = async (argv) => {
39+
const project_name = argv.name;
40+
41+
let proc = child_process.spawn('git', ['clone', TEMPLATE_URL, project_name],
42+
{ stdio: 'inherit' });
43+
44+
// You would just need to register the error event, or else it can't print
45+
// the help instruction below.
46+
proc.on('error', function () { });
47+
48+
proc.on('close', function (code) {
49+
if (code == 0) {
50+
console.log('✓ Done cloning the ELPA template');
51+
console.log('');
52+
process.chdir(project_name);
53+
_cloned(argv);
54+
return;
55+
}
56+
// Help instruction here!
57+
console.log('✗ Error while cloning template project');
58+
console.log('');
59+
console.log(' [1] Make sure you have git installed and has the right permission');
60+
process.stdout.write(` [2] Failed because of the target directory isn't empty`);
61+
});
62+
}
63+
64+
/* Operations after _cloned */
65+
async function _cloned(argv) {
66+
console.log('Initialize the Eask-file for your project...');
67+
await init.create_eask_file();
68+
UTIL.e_call(argv, 'create/elpa');
69+
}

cmds/create/package.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (C) 2022-2023 Jen-Chieh Shen
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with GNU Emacs; see the file COPYING. If not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
"use strict";
21+
22+
const child_process = require('child_process');
23+
24+
const init = require('../core/init');
25+
26+
exports.command = ['package <name>', 'pkg <name>'];
27+
exports.desc = 'Create a new package';
28+
exports.builder = {
29+
name: {
30+
description: 'new project name',
31+
requiresArg: false,
32+
type: 'string',
33+
},
34+
};
35+
36+
const TEMPLATE_URL = 'https://github.com/emacs-eask/template-elisp';
37+
38+
exports.handler = async (argv) => {
39+
const project_name = argv.name;
40+
41+
let proc = child_process.spawn('git', ['clone', TEMPLATE_URL, project_name],
42+
{ stdio: 'inherit' });
43+
44+
// You would just need to register the error event, or else it can't print
45+
// the help instruction below.
46+
proc.on('error', function () { });
47+
48+
proc.on('close', function (code) {
49+
if (code == 0) {
50+
console.log('✓ Done cloning the elisp package template');
51+
console.log('');
52+
process.chdir(project_name);
53+
_cloned(argv);
54+
return;
55+
}
56+
// Help instruction here!
57+
console.log('✗ Error while cloning template project');
58+
console.log('');
59+
console.log(' [1] Make sure you have git installed and has the right permission');
60+
process.stdout.write(` [2] Failed because of the target directory isn't empty`);
61+
});
62+
};
63+
64+
/* Operations after _cloned */
65+
async function _cloned(argv) {
66+
console.log('Initialize the Eask-file for your project...');
67+
await init.create_eask_file();
68+
UTIL.e_call(argv, 'create/package');
69+
}

docs/content/en/Contributing/Documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To set up the website locally, you need to first install the theme:
3232
git clone https://github.com/emacs-eask/cli --recurse-submodules
3333

3434
# Navgiate to `docs/theme/geekdoc` folder
35-
cd path/to/cli/docs/theme/geekdoc/
35+
cd ./docs/theme/geekdoc/
3636

3737
# Build the themes
3838
npm install && npm run build
@@ -42,7 +42,7 @@ Then run the `hugo` command:
4242

4343
```sh
4444
# Navigate back to `docs` folder
45-
cd path/to/cli/docs/
45+
cd ./docs/
4646

4747
# Run hugo server locally
4848
hugo server

docs/content/en/Development API/_index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ Return a list of Eask files from DIR.
208208
Consider following directory tree:
209209

210210
```
211-
- root
212-
- Eask
213-
- Eask.28
214-
- Eask.29
211+
. root
212+
├── Eask
213+
├── Eask.28
214+
└── Eask.29
215215
```
216216

217217
The following output is with Emacs 28.1:
@@ -227,12 +227,12 @@ Find the Eask-file from START-PATH.
227227
Consider following directory tree:
228228

229229
```
230-
-project
231-
- src
232-
- config.el
233-
- Eask
234-
- Eask.28
235-
- Eask.29
230+
.project
231+
├─ src
232+
│ └── config.el
233+
├── Eask
234+
├── Eask.28
235+
└── Eask.29
236236
```
237237

238238
The following output is with Emacs 28.1:

docs/content/en/Getting Started/Basic Usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Commands:
3232
clean <type> Delete various files produced during building
3333
compile [names..] Byte compile all Emacs Lisp files in the package
3434
concat [names..] Concatenate elisp files [aliases: concatenate]
35-
create <name> Create a new elisp project [aliases: new]
35+
create <type> Create a new elisp project
3636
emacs [args..] Execute emacs with the appropriate environment
3737
eval [form] Evaluate lisp form with a proper PATH
3838
path Print the PATH (exec-path) from workspace [aliases: exec-path]

docs/content/en/Getting Started/Commands and options.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ $ eask [GLOBAL-OPTIONS] [COMMAND] [COMMAND-OPTIONS] [COMMAND-ARGUMENTS]
1313

1414
# 🚩 Core
1515

16-
## 🔍 eask create
17-
18-
Create an elisp project with the default `Eask`-file and CI/CD support.
19-
20-
{{< hint info >}}
21-
💡 The template project is located in https://github.com/emacs-eask/template-elisp
22-
{{< /hint >}}
23-
2416
## 🔍 eask init
2517

2618
Eask will generate file like:
@@ -309,6 +301,24 @@ Download package archives.
309301
$ eask [GLOBAL-OPTIONS] refresh
310302
```
311303

304+
# 🚩 Creating
305+
306+
## 🔍 eask create package
307+
308+
Create a new elisp project with the default `Eask`-file and CI/CD support.
309+
310+
{{< hint info >}}
311+
💡 The template project is located in https://github.com/emacs-eask/template-elisp
312+
{{< /hint >}}
313+
314+
## 🔍 eask create elpa
315+
316+
Create a new ELPA using [github-elpa](https://github.com/10sr/github-elpa).
317+
318+
{{< hint info >}}
319+
💡 The template project is located in https://github.com/emacs-eask/template-elpa
320+
{{< /hint >}}
321+
312322
# 🚩 Cleaning
313323

314324
## 🔍 eask clean workspace

docs/content/en/Getting Started/Directory Structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 350
55

66
{{< toc >}}
77

8-
Running the **`eask create`** generator from the command-line will create
8+
Running the **`eask create package`** generator from the command-line will create
99
a directory with the following structure:
1010

1111
```

0 commit comments

Comments
 (0)