#############################################################################################
#############################################################################################
##
## INIT-WEBCOMPONENTS
##
#############################################################################################
#############################################################################################

# @see .PHONY https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
.PHONY: init-webcomponent

# The default directories are defined in the 
# directories-standard.mk file, but all other 
# targets can define directories as well.

$(PROJECT_DIRECTORIES):
	$(foreach path,$(PROJECT_DIRECTORIES),\
    		$(shell $(MKDIR) -p $(path)))

## init standard project	
init-webcomponent: $(PROJECT_DIRECTORIES) $(PROJECT_ROOT).gitignore $(DEVELOPMENT_PATH)package.json $(APPLICATION_PATH)package.json $(PROJECT_ROOT)README.md  $(LICENSE_PATH)LICENSE $(APPLICATION_PATH)LICENSE
	$(ECHOMARKER) "Run init-webcomponent"
	$(ECHO) "Done"

#############################################################################################
#############################################################################################
##
## LICENSE
##
#############################################################################################
#############################################################################################

export LICENSE_FILE_CONTENT
$(LICENSE_PATH)LICENSE:
	$(QUIET) $(ECHO) "$$LICENSE_FILE_CONTENT" >> $@

export LICENSE_AGPL_FILE_CONTENT
$(APPLICATION_PATH)LICENSE:
	$(QUIET) $(ECHO) "$$LICENSE_AGPL_FILE_CONTENT" >> $@

#############################################################################################
#############################################################################################
##
## README
##
#############################################################################################
#############################################################################################

export README_FILE_CONTENT
$(PROJECT_ROOT)README.md:
	$(QUIET) $(ECHO) "$$README_FILE_CONTENT" >> $@


#############################################################################################
#############################################################################################
##
## PACKAGE JSON
##
#############################################################################################
#############################################################################################
define WEBCOMPONENTS_PACKAGE_CONTENT
{
  "name": "component-$(COMPONENT_SLUG)",
  "version": "0.1.0",
  "description": "component $(COMPONENT_NAME)",
  "repository": {
    "type": "git",
    "url": "https://gitlab.schukai.com/oss/libraries/javascript/web-components/$(COMPONENT_SLUG).git"
  },
  "keywords": [
    "web",
    "dom",
    "css",
    "mobile-first",
    "app",
    "front-end",
    "ui",
    "form",
    "templates",
    "schukai",
    "component",
    "web-component",
    "monster"
  ],
  "dependencies": {
    "@popperjs/core": "^2.9.2",
    "@schukai/monster": "^2.0.8"
  },
  "main": "source/component.mjs",
  "module": "source/component.mjs",
  "type": "module",
  "homepage": "https://monsterjs.org/",
  "repository": {
    "type": "git",
    "url": "https://gitlab.schukai.com/oss/libraries/javascript/web-components/$(COMPONENT_SLUG).git"
  },
  "author": "schukai GmbH",
  "license": "AGPL 3.0"
}
endef

export WEBCOMPONENTS_PACKAGE_CONTENT
$(APPLICATION_PATH)package.json:
	$(QUIET) $(ECHO) "$$WEBCOMPONENTS_PACKAGE_CONTENT" >> $@

#############################################################################################
#############################################################################################
##
## BUILD PACKAGE JSON
##
#############################################################################################
#############################################################################################
define WEBCOMPONENTS_BUILD_PACKAGE_CONTENT
{
  "name": "component-$(COMPONENT_SLUG)",
  "version": "0.1.0",
  "description": "component $(COMPONENT_NAME)",
  "repository": {
    "type": "git",
    "url": "https://gitlab.schukai.com/oss/libraries/javascript/web-components/$(COMPONENT_SLUG).git"
  },
  "scripts": {
    "test": "npx mocha --recursive test/cases/",
    "web-test": "script/web-test.sh",
    "publish": "script/release-and-publish.sh",
    "build-doc": "script/build-doc.sh"
  },
  "type": "module",
  "author": "schukai GmbH",
  "license": "see LICENSE file",
  "dependencies": {
    "@popperjs/core": "^2.11.2",
    "@schukai/monster": "^2.0.8"
  },
  "devDependencies": {
    "@peculiar/webcrypto": "^1.4.0",
    "btoa": "^1.2.1",
    "c8": "^7.12.0",
    "chai": "^4.3.6",
    "chai-dom": "^1.11.0",
    "clean-jsdoc-theme": "^4.1.6",
    "create-polyfill-service-url": "^2.2.6",
    "crypt": "^0.0.2",
    "esbuild": "^0.14.53",
    "flow-bin": "^0.184.0",
    "fs": "^0.0.1-security",
    "graphviz": "^0.0.9",
    "jsdoc": "^3.6.11",
    "jsdoc-external-example": "github:volker-schukai/jsdoc-external-example",
    "jsdoc-plantuml": "^1.0.2",
    "jsdom": "^19.0.0",
    "jsdom-global": "^3.0.2",
    "mocha": "^10.0.0",
    "node-plantuml": "^0.9.0",
    "sinon": "^14.0.0",
    "url": "^0.11.0",
    "url-exist": "3.0.0",
    "util": "^0.12.4"
  }
}
endef

export WEBCOMPONENTS_BUILD_PACKAGE_CONTENT
$(DEVELOPMENT_PATH)package.json:
	$(QUIET) $(ECHO) "$$WEBCOMPONENTS_BUILD_PACKAGE_CONTENT" >> $@

######