Skip to content

Commit

Permalink
fix: assets destinations renamed (#26)
Browse files Browse the repository at this point in the history
Bucket paths re-evaluated to be more precise and context with packages.
  • Loading branch information
miguelramos authored Sep 12, 2022
1 parent 9e0f38c commit 5d2e558
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"../sublime-sdk",
"action",
"--type",
"branch",
"tag",
"--env",
"develop"
"production"
]
},
{
Expand Down
25 changes: 12 additions & 13 deletions cmd/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,17 @@ func (ctx *ActionFlags) DeployArtifacts() {
os.Exit(0)
}

// patern: <bucket>/<package-json-name>/<package-json-version>(dev-SNAPSHOT)
var destinationFolder = ""
var pkgVersion = ""
if isBranch {
destinationFolder = fmt.Sprintf("%s@%s-SNAPSHOT", pkg.Name, packageJson.Version)
//destinationFolder = fmt.Sprintf("%s@%s-SNAPSHOT", pkg.Name, packageJson.Version)
destinationFolder = fmt.Sprintf("%s/%s-SNAPSHOT", packageJson.Name, packageJson.Version)
pkgVersion = fmt.Sprintf("%s-SNAPSHOT", packageJson.Version)
} else {
destinationFolder = fmt.Sprintf("%s@%s", pkg.Name, packageJson.Version)
//destinationFolder = fmt.Sprintf("%s@%s", pkg.Name, packageJson.Version)
destinationFolder = fmt.Sprintf("%s/%s", packageJson.Name, packageJson.Version)
pkgVersion = packageJson.Version
}

distFiles, err := utils.PathWalk(packageDistDir)
Expand All @@ -203,23 +209,16 @@ func (ctx *ActionFlags) DeployArtifacts() {
Name: pkg.Name,
Scope: scope,
Repo: ctx.Sublime.Repo,
Version: packageJson.Version,
Version: pkgVersion,
Scripts: &core.ManifestScripts{
Main: fmt.Sprintf("%s/%s", manifestBaseLink, filepath.Base(packageJson.Main)),
Esm: fmt.Sprintf("%s/%s", manifestBaseLink, filepath.Base(packageJson.Module)),
NoModule: fmt.Sprintf("%s/%s", manifestBaseLink, filepath.Base(packageJson.Main)),
Module: fmt.Sprintf("%s/%s", manifestBaseLink, filepath.Base(packageJson.Module)),
},
Styles: make([]string, 0),
Docs: fmt.Sprintf("https://websublime.dev/organization/%s/%s/%s", ctx.Sublime.Organization, ctx.Sublime.Name, pkg.Name),
})

var manifestDestination = ""
if isBranch {
manifestDestination = fmt.Sprintf("manifests/%s/%s", packageJson.Name, string(env))
} else {
manifestDestination = packageJson.Name
}

manifest, err := supabase.Upload(ctx.Sublime.Organization, manifestFile.Name(), manifestDestination)
manifest, err := supabase.Upload(ctx.Sublime.Organization, manifestFile.Name(), destinationFolder)
if err != nil {
utils.WarningOut(err.Error())
os.Exit(0)
Expand Down
1 change: 1 addition & 0 deletions cmd/templates/lib-package-solid.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-postcss-lit": "^2.0.0",
"rollup-plugin-typescript2": "^0.31.2",
"@rollup/plugin-replace": "^4.0.0",
"sass": "^1.51.0",
"ts-jest": "^26.1.1",
"typescript": "^4.5.4",
Expand Down
1 change: 1 addition & 0 deletions cmd/templates/lib-package-vue.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-postcss-lit": "^2.0.0",
"rollup-plugin-typescript2": "^0.31.2",
"@rollup/plugin-replace": "^4.0.0",
"sass": "^1.51.0",
"ts-jest": "^26.1.1",
"typescript": "^4.5.4",
Expand Down
1 change: 1 addition & 0 deletions cmd/templates/lib-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-postcss-lit": "^2.0.0",
"rollup-plugin-typescript2": "^0.31.2",
"@rollup/plugin-replace": "^4.0.0",
"sass": "^1.51.0",
"ts-jest": "^26.1.1",
"typescript": "^4.5.4",
Expand Down
7 changes: 4 additions & 3 deletions cmd/templates/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"scope": "{{ .Scope }}",
"repo": "{{ .Repo }}",
"scripts": {
"main": "{{ .Scripts.Main }}",
"esm": "{{ .Scripts.Esm }}"
"nomodule": "{{ .Scripts.Main }}",
"module": "{{ .Scripts.Esm }}"
},
"styles": {{ .Styles }},
"docs": "{{ .Docs }}"
"docs": "{{ .Docs }}",
"global": false
}
7 changes: 7 additions & 0 deletions cmd/templates/vite-config-lit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-import-module-exports */
import path from 'path';

import replace from '@rollup/plugin-replace';
import { workspacesAlias } from '{{ .Scope }}/vite';
import postcss from 'rollup-plugin-postcss';
import postcssLit from 'rollup-plugin-postcss-lit';
Expand Down Expand Up @@ -45,6 +46,12 @@ module.exports = defineConfig({
}
},
plugins: [
replace({
'process.env.NODE_ENV':
process.env.NODE_ENV === 'production'
? JSON.stringify('production')
: JSON.stringify('development')
}),
postcss({
inject: false
}),
Expand Down
7 changes: 7 additions & 0 deletions cmd/templates/vite-config-solid.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-import-module-exports */
import path from 'path';

import replace from '@rollup/plugin-replace';
import { workspacesAlias } from '{{ .Scope }}/vite';
import postcss from 'rollup-plugin-postcss';
import solidPlugin from 'vite-plugin-solid';
Expand Down Expand Up @@ -45,6 +46,12 @@ module.exports = defineConfig({
}
},
plugins: [
replace({
'process.env.NODE_ENV':
process.env.NODE_ENV === 'production'
? JSON.stringify('production')
: JSON.stringify('development')
}),
postcss({
inject: false
}),
Expand Down
7 changes: 7 additions & 0 deletions cmd/templates/vite-config-typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-import-module-exports */
import path from 'path';

import replace from '@rollup/plugin-replace';
import { workspacesAlias } from '{{ .Scope }}/vite';
import postcss from 'rollup-plugin-postcss';
import { defineConfig } from 'vite';
Expand Down Expand Up @@ -44,6 +45,12 @@ module.exports = defineConfig({
}
},
plugins: [
replace({
'process.env.NODE_ENV':
process.env.NODE_ENV === 'production'
? JSON.stringify('production')
: JSON.stringify('development')
}),
postcss({
inject: false
}),
Expand Down
7 changes: 7 additions & 0 deletions cmd/templates/vite-config-vue.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable import/no-import-module-exports */
import path from 'path';

import replace from '@rollup/plugin-replace';
import { workspacesAlias } from '{{ .Scope }}/vite';
import postcss from 'rollup-plugin-postcss';
import vue from '@vitejs/plugin-vue';
Expand Down Expand Up @@ -45,6 +46,12 @@ module.exports = defineConfig({
}
},
plugins: [
replace({
'process.env.NODE_ENV':
process.env.NODE_ENV === 'production'
? JSON.stringify('production')
: JSON.stringify('development')
}),
postcss({
inject: false
}),
Expand Down
2 changes: 2 additions & 0 deletions cmd/templates/workflow-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
tags:
- '*'
- '**'
- '*/*'

env:
CI: true
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var (
Version string = "v0.1.6"
Version string = "v0.1.7"
BuildTime string = fmt.Sprintf("%d", time.Now().Unix())
)

Expand Down
4 changes: 2 additions & 2 deletions core/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
)

type ManifestScripts struct {
Main string `json:"main"`
Esm string `json:"esm"`
NoModule string `json:"nomodule"`
Module string `json:"module"`
}

type Manifest struct {
Expand Down

0 comments on commit 5d2e558

Please sign in to comment.