107 lines
2.5 KiB
TypeScript
107 lines
2.5 KiB
TypeScript
import * as path from 'path'
|
|
import { sync as read } from "@plastichub/fs/read"
|
|
|
|
import {
|
|
products,
|
|
products_test
|
|
} from './machines'
|
|
|
|
import {
|
|
productLaserTask,
|
|
productCADTask
|
|
} from './product'
|
|
|
|
|
|
const getProducts = (branch: string) => {
|
|
const all = read("./config/machines.json", "json") || {}
|
|
if(branch){
|
|
return all[branch] || []
|
|
}else{
|
|
return Object.values(all).flat()
|
|
}
|
|
}
|
|
|
|
export const grunt = (grunt) => {
|
|
grunt.initConfig({
|
|
pkg: grunt.file.readJSON("package.json"),
|
|
'cad': {
|
|
json: {
|
|
src: products,
|
|
output: '${SRC_DIR}/${SRC_NAME}.+(json)'
|
|
},
|
|
html: {
|
|
src: products,
|
|
output: '${SRC_DIR}/../resources/${SRC_NAME}.+(html)',
|
|
},
|
|
step: {
|
|
src: products,
|
|
output: '${SRC_DIR}/${SRC_NAME}.+(step)'
|
|
},
|
|
bom: {
|
|
src: products,
|
|
output: '${SRC_DIR}/../resources/${SRC_NAME}.+(xlsx)'
|
|
},
|
|
one: [grunt.option('product')]
|
|
},
|
|
'laser': {
|
|
products: {
|
|
src: products_test,
|
|
options: {
|
|
clear: false,
|
|
debug: true,
|
|
verbose: true
|
|
}
|
|
}
|
|
},
|
|
sshexec: {
|
|
update: {
|
|
debug: true,
|
|
verbose: true,
|
|
commands: 'sh update-osr.sh'
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
grunt.loadNpmTasks('grunt-parallel')
|
|
grunt.loadNpmTasks("grunt-extend-config")
|
|
|
|
grunt.registerTask('laser', [
|
|
'laser:products'
|
|
])
|
|
const product_sync_tasks = []
|
|
const product_laser_tasks = []
|
|
const product_cad_tasks = []
|
|
const product_git_tasks = []
|
|
const product_all_tasks = []
|
|
|
|
const productTasks = (items) => {
|
|
items.forEach((i) => {
|
|
productCADTask(grunt, i, {}, product_cad_tasks)
|
|
productLaserTask(grunt, i, {}, product_laser_tasks)
|
|
})
|
|
}
|
|
|
|
const all = getProducts("current")
|
|
productTasks(all)
|
|
|
|
|
|
|
|
grunt.registerTask('products_update', [
|
|
'products-cad',
|
|
'products-laser'
|
|
])
|
|
|
|
grunt.registerTask('products_sync', [
|
|
'sshexec:update'
|
|
])
|
|
|
|
grunt.registerTask('products_full', [
|
|
'products_update',
|
|
'products_sync'
|
|
])
|
|
|
|
require("@plastichub/osr-tasks").initConfig(grunt, {})
|
|
};
|
|
|
|
module.exports = grunt |