diff --git a/cli/vm/compile.ts b/cli/vm/compile.ts index caff6d25f..7800d70cc 100644 --- a/cli/vm/compile.ts +++ b/cli/vm/compile.ts @@ -45,7 +45,7 @@ export function compile(compileConfig: dataform.ICompileConfig) { vmIndexFileName, 'return require("@dataform/core").version || "0.0.0"' ); - if (semver.lt(dataformCoreVersion, "3.0.0")) { + if (semver.lt(dataformCoreVersion, "3.0.0-alpha.0")) { throw new Error("@dataform/core ^3.0.0 required."); } diff --git a/core/main_test.ts b/core/main_test.ts index b2f714802..656765b49 100644 --- a/core/main_test.ts +++ b/core/main_test.ts @@ -195,7 +195,7 @@ select 1 AS \${dataform.projectConfig.vars.selectVar}` expect(asPlainObject(result.compile.compiledGraph)).deep.equals( asPlainObject({ - dataformCoreVersion: "3.0.0", + dataformCoreVersion: "3.0.0-alpha.0", graphErrors: {}, projectConfig: { defaultDatabase: "dataform", @@ -342,7 +342,7 @@ select 1 AS \${dataform.projectConfig.vars.columnVar}` } } ], - dataformCoreVersion: "3.0.0", + dataformCoreVersion: "3.0.0-alpha.0", graphErrors: {}, projectConfig: { defaultLocation: "us", diff --git a/packages/@dataform/cli/BUILD b/packages/@dataform/cli/BUILD index 56ae623a6..5429abcd5 100644 --- a/packages/@dataform/cli/BUILD +++ b/packages/@dataform/cli/BUILD @@ -1,6 +1,6 @@ load("//tools:ts_library.bzl", "ts_library") load("//:version.bzl", "DF_VERSION") -load("//packages:index.bzl", "pkg_bundle", "pkg_json", "pkg_npm_tar") +load("//packages:index.bzl", "LICENSE_HEADER", "add_license_header_to_file", "pkg_bundle", "pkg_json", "pkg_npm_tar") package(default_visibility = ["//visibility:public"]) @@ -65,9 +65,9 @@ pkg_json( pkg_bundle( name = "bundle", - args = ["--banner='#!/usr/bin/env node'"], - entry_point = "index.ts", allow_node_builtins = True, + args = ["--banner='#!/usr/bin/env node\n" + LICENSE_HEADER + "'"], + entry_point = "index.ts", externals = externals, deps = [ ":cli", @@ -76,9 +76,9 @@ pkg_bundle( pkg_bundle( name = "worker_bundle", - args = ["--banner='#!/usr/bin/env node'"], - entry_point = "worker.ts", allow_node_builtins = True, + args = ["--banner='#!/usr/bin/env node\n" + LICENSE_HEADER + "'"], + entry_point = "worker.ts", externals = externals, deps = [ ":cli", @@ -91,5 +91,6 @@ pkg_npm_tar( ":bundle", ":package.json", ":worker_bundle", + ], ) diff --git a/packages/@dataform/core/BUILD b/packages/@dataform/core/BUILD index 669fc6b6f..a5fb23c48 100644 --- a/packages/@dataform/core/BUILD +++ b/packages/@dataform/core/BUILD @@ -1,6 +1,6 @@ load("//tools:ts_library.bzl", "ts_library") load("//:version.bzl", "DF_VERSION") -load("//packages:index.bzl", "pkg_bundle", "pkg_bundle_dts", "pkg_json", "pkg_npm_tar") +load("//packages:index.bzl", "pkg_json", "pkg_npm_tar", "add_license_header_to_file") load("//tools/common:copy.bzl", "copy_file") package(default_visibility = ["//visibility:public"]) @@ -29,11 +29,11 @@ load("@build_bazel_rules_nodejs//:index.bzl", "npm_package_bin") npm_package_bin( name = "bundle", outs = [ - "bundle.js", + "bundle_no_license.js", ], args = [ "--config=$(location webpack.config.js)", - "--output=$(location bundle.js)", + "--output=$(location bundle_no_license.js)", "--mode=production" ], data = [ @@ -55,17 +55,23 @@ pkg_json( version = DF_VERSION, ) -copy_file( - name = "core_proto", - src = "//protos:core.proto", - out = "core.proto", +add_license_header_to_file( + name="core_proto_with_license", + from_file="//protos:core.proto", + to_file="core.proto", +) + +add_license_header_to_file( + name="bundle_with_license", + from_file="bundle", + to_file="bundle.js", ) pkg_npm_tar( name = "package", deps = [ - ":bundle", + ":bundle_with_license", ":package.json", - ":core.proto", + ":core_proto_with_license", ], ) diff --git a/packages/index.bzl b/packages/index.bzl index 18a857d02..db3360bb4 100644 --- a/packages/index.bzl +++ b/packages/index.bzl @@ -67,3 +67,34 @@ def pkg_npm_tar(name, srcs = [], deps = []): cmd = "tar -cvzf $(location {name}.tgz) -C $(location :{name})/.. --dereference {name}" .format(name = name), ) + +LICENSE_HEADER = """// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +""" + +def add_license_header_to_file(name, from_file, to_file): + """ + Adds the Apache 2.0 license header to a file. This is not done in-place because Bazel requires + separate output and input files. + """ + native.genrule( + name=name, + srcs=[from_file], + outs=[to_file], + cmd=( + ( + "echo '{license_header}' | cat - $(location {from_file}) > $(location {to_file})" + ).format(from_file=from_file, to_file=to_file, license_header=LICENSE_HEADER) + ), + ) diff --git a/version.bzl b/version.bzl index 58b7b25d3..6689c3325 100644 --- a/version.bzl +++ b/version.bzl @@ -1,3 +1,3 @@ # NOTE: If you change the format of this line, you must change the bash command # in /scripts/publish to extract the version string correctly. -DF_VERSION = "3.0.0" +DF_VERSION = "3.0.0-alpha.0"