Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2023-04-20 00:05:28 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
18d88cce5468ce7b4bd5dcc06bbf22d37fac7bd4
18d88cce
1 parent
ca8b9b92
setting tool to agregate library descriptions
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
example/package.json
tools/arcsrepos.js
example/package.json
0 → 100644
View file @
18d88cc
{
"type"
:
"module"
}
\ No newline at end of file
tools/arcsrepos.js
0 → 100644
View file @
18d88cc
/**
* This tool is intended to build a description of a repository of components
*/
import
process
from
'node:process'
;
import
*
as
fs
from
'node:fs'
;
import
path
from
'node:path'
;
/**
* possible arguments:
* - "-o" with output file
* - "-d" with input directory
* - "-h" or "--help" displays usage
*/
let
outputFile
=
"repos.json"
;
let
inputDir
=
"."
;
const
usage
=
function
(
idx
)
{
console
.
log
(
path
.
basename
(
process
.
argv
[
1
]),
" [-o output_file] [-d component_dir] [-h]"
);
console
.
log
(
"\toutput_file is the generated repository json file (by default 'repos.json')"
);
console
.
log
(
"\tcomponent_dir is the directory storing components (by default '.')"
);
return
0
;
};
const
helpers
=
{
'-h'
:
usage
,
'--help'
:
usage
,
'-o'
:
function
(
idx
)
{
outputFile
=
process
.
argv
[
idx
+
1
];
return
1
;
},
'-d'
:
function
(
idx
)
{
inputDir
=
process
.
argv
[
idx
+
1
];
return
1
;
}
};
for
(
let
i
=
2
;
i
<
process
.
argv
.
length
;
i
++
)
{
if
(
helpers
.
hasOwnProperty
(
process
.
argv
[
i
]))
{
let
shift
=
helpers
[
process
.
argv
[
i
]](
i
);
i
+=
shift
;
}
}
const
getFiles
=
function
(
dir
,
filter
,
files_
)
{
files_
=
files_
||
[];
let
files
=
fs
.
readdirSync
(
dir
);
for
(
let
i
in
files
)
{
let
name
=
dir
+
'/'
+
files
[
i
];
let
stat
=
fs
.
statSync
(
name
);
if
(
stat
.
isDirectory
())
{
getFiles
(
name
,
files_
);
}
else
{
if
(
path
.
extname
(
name
)
===
filter
)
files_
.
push
(
name
);
}
}
return
files_
;
};
const
files
=
getFiles
(
path
.
resolve
(
inputDir
),
'.js'
);
const
list
=
{};
files
.
forEach
(
async
(
element
)
=>
{
try
{
const
components
=
await
import
(
path
.
resolve
(
element
));
if
(
components
.
__arcs__
!==
undefined
)
{
console
.
log
(
`
${
element
}
contains a description`
);
Object
.
assign
(
list
,
components
.
__arcs__
);
}
else
{
console
.
log
(
`
${
element
}
does not contain a description`
);
}
}
catch
(
e
)
{
console
.
log
(
`
${
element
}
is not a valid component`
);
}
});
console
.
log
(
list
);
Please
register
or
login
to post a comment