@@ -2,43 +2,7 @@ const core = require('@actions/core');
22const process = require ( 'child_process' ) ;
33const fs = require ( 'fs' ) ;
44const path = require ( 'path' ) ;
5-
6- /**
7- * Detects if we are in a plugin or template repo and returns the target directory
8- *
9- * @returns {string }
10- */
11- function getTargetDir ( ) {
12- let type = '' ;
13- let dir = '' ;
14- let info = '' ;
15- if ( fs . existsSync ( 'plugin.info.txt' ) ) {
16- type = 'plugin' ;
17- dir = 'plugins' ;
18- info = 'plugin.info.txt' ;
19- } else if ( fs . existsSync ( 'template.info.txt' ) ) {
20- type = 'template' ;
21- dir = 'tpl' ;
22- info = 'template.info.txt' ;
23- } else {
24- throw new Error ( 'No plugin.info.txt or template.info.txt found!' ) ;
25- }
26-
27- const data = fs . readFileSync ( info , 'utf8' ) ;
28- const lines = data . split ( '\n' ) ;
29- const baseLine = lines . find ( line => line . trim ( ) . startsWith ( 'base' ) ) ;
30- if ( ! baseLine ) {
31- throw new Error ( 'No base found in info file!' ) ;
32- }
33- const [ , base ] = baseLine . split ( / \s + / ) ;
34- const targetDir = `lib/${ dir } /${ base } ` ;
35-
36- core . setOutput ( 'type' , type ) ;
37- core . setOutput ( 'dir' , targetDir ) ;
38- core . setOutput ( 'base' , base ) ;
39-
40- return targetDir ;
41- }
5+ const dwUtils = require ( '../dokuwikiUtils' ) ;
426
437/**
448 * Moves all contents of a directory to another directory
@@ -71,7 +35,7 @@ function moveContents(sourceDir, destinationDir) {
7135}
7236
7337/**
74- * Installs additional plugin from requirements.txt if it exists
38+ * Installs additional plugins from requirements.txt if it exists
7539 */
7640function installRequirements ( dir ) {
7741 if ( ! fs . existsSync ( `${ dir } /requirements.txt` ) ) {
@@ -95,17 +59,24 @@ function installRequirements(dir) {
9559
9660async function main ( ) {
9761 const branch = core . getInput ( 'branch' , { required : true } ) ;
98- const targetDir = getTargetDir ( ) ;
62+ const config = dwUtils . loadExtensionInfo ( ) ;
9963
100- console . log ( `Moving plugin to ${ targetDir } ...` ) ;
101- moveContents ( '.' , targetDir ) ;
64+ console . log ( `Moving plugin to ${ config . dir } ...` ) ;
65+ moveContents ( '.' , config . dir ) ;
10266
10367 // checkout DokuWiki into current directory (no clone because dir isn't empty)
10468 console . log ( `Cloning DokuWiki ${ branch } ...` ) ;
10569 process . execFileSync ( 'git' , [ 'init' ] ) ;
10670 process . execFileSync ( 'git' , [ 'pull' , 'https://github.com/dokuwiki/dokuwiki.git' , branch ] ) ;
10771
108- installRequirements ( targetDir ) ;
72+ installRequirements ( config . dir ) ;
73+
74+ // set outputs
75+ core . setOutput ( 'type' , config . type ) ;
76+ core . setOutput ( 'dir' , config . dir ) ;
77+ core . setOutput ( 'base' , config . base ) ;
78+ core . setOutput ( 'minphp' , config . minphp ) ;
79+ core . setOutput ( 'maxphp' , config . maxphp ) ;
10980}
11081
11182
0 commit comments