Skip to content

snowyu/isdk-demo.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cwd dest tasks src logger overwrite force raiseError
./wiki
./output/
mkdir
echo
template
copy
<
overwrite
echo
hi
this a echo string
**/*.md
**/
!**/node_modules
!**/.*
!./output
level
debug
true
false
false

ISDK Demo

This file shows the isdk building concept and how to process the folder. It's just a beginning.

The distinguishing features of the ISDK building are:

  • Each file are an object. The folder(directory) is a special file object too.
  • Each file could have configuration. These configuration items are the additional attributes to the file object.
  • The index file(README.md) of a Folder is the folder's configuration.
  • The folder(directory) tree is the inheritance tree of the file object.
    • The configuration of the file or subdirectory inherits from the parent directory.

This README.md file is the root configuration file of the folder. The configuration is the front-matter at top of the file.

This demo will process the mardown files(".md") in the wiki folder, and the text files(".txt") int the wiki/text folder, use the default template engine - lodash. And copy these files to the output folder.

first you should download this demo and install dependency packages:

git clone [email protected]:snowyu/isdk-demo.js.git isdk-demo
cd isdk-demo/
npm install

At last run the magic in the isdk-demo folder:

npm run build

now try again, it will report an error on copy task:

EEXIST

This means the dest file is already exists.

You can set the overwrite option in the copy task to true to avoid this. or delete this argument in the copy task simply. the file's overwrite option would be avaiable.

Configuration items

  • dest (String): The destination directory to output(optional). defaults to "./public".
  • cwd (String): The current working directory to process(optional). defaults to '.', this option only for the root folder of project.
  • src (String|Array String): The source file filter.
    • The first letter "!" indicates a mismatch.
      • Note: The order is important, if the first one is not match, then the latter match all are failed.
    • "**" Indicates match any subdirectory
  • tasks: the task list to execute,task list according to the order they appear, one by one. Only for the files(not directories).
    • force (Boolean): whether force to continue even though some error occur. default to false.
    • raiseError (Boolean): whether throw error exception. default to false.
  • logger: the configuraion options of the logger
    • level: the logging level, defaults to 'error'
  • overwrite (Boolean): whether overwrite the already exist files. used via copy task. default to false.

tasks

  • mkdir task: Create a new directory and any necessary subdirectories at dest path.
    • dest (String): the new directory to create.
  • echo task: just echo the input options object argument to the result output.
    • you can test the arguments of a task here.
  • template task: Process the contents of a file via the default template engine(the first registered template engine).
    • engine (String): the template engine name(optional).
    • ...: the specified engine options(optional).
  • copy task: copy the file to the dest.
    • dest (String): the dest folder or file name.
    • overwrite (Boolean): whether overwrite the dest file if it's exist. default to false.

Note: The default argument(object) passed to the task is this file object if no specifed the parameter of the task.

License

MIT

About

the ISDK building system demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published