Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 37 additions & 23 deletions ensure-packages-built.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ const fs = require("fs");
ensurePackagesBuilt();
/**
* if packages are not built or if they are old builds then:
*
*
* 1. run npm install from "packages/live-share-react".
* live-share-react uses all other live-share packages as dependencies, hence will install all packages needed to build live-share packages.
* 2. run npm run build:packages from root
*/
async function ensurePackagesBuilt() {
const rootFolderPath = await getRootFolder();
const currentGitHash = await getGitHash()
const currentGitHash = await getGitHash();

const packagesNotBuilt = !fs.existsSync(`${rootFolderPath}/node_modules/@microsoft/live-share-react/bin`);
const packagesNotBuilt = !fs.existsSync(
`${rootFolderPath}/node_modules/@microsoft/live-share-react/bin`
);
const isOldBuild = currentGitHash !== getBuildData()?.lastGitHashBuilt;
if (packagesNotBuilt || isOldBuild) {
await npmInstallFromLiveShareReact();
build();
}

async function getGitHash() {
const currentGitHash = childProcess.spawn("git", ["rev-parse", "HEAD"], {
shell: true,
cwd: process.cwd(),
});
const currentGitHash = childProcess.spawn(
"git",
["rev-parse", "HEAD"],
{
shell: true,
cwd: process.cwd(),
}
);
return new Promise((resolve, reject) => {
currentGitHash.stdout.on("data", (data) => {
const hash = data.toString().slice(0, -1);
Expand All @@ -40,15 +46,19 @@ async function ensurePackagesBuilt() {
reject(code);
}
});
})
});
}

async function getRootFolder() {
const rootDir = childProcess.spawn("git", ["rev-parse", " --show-toplevel"], {
shell: true,
cwd: process.cwd(),
});

const rootDir = childProcess.spawn(
"git",
["rev-parse", " --show-toplevel"],
{
shell: true,
cwd: process.cwd(),
}
);

return new Promise((resolve, reject) => {
rootDir.stdout.on("data", (data) => {
const path = data.toString().slice(0, -1);
Expand All @@ -59,7 +69,7 @@ async function ensurePackagesBuilt() {
reject(code);
}
});
})
});
}

// live-share-react uses all other live-share packages as dependencies
Expand All @@ -70,24 +80,28 @@ async function ensurePackagesBuilt() {
cwd: `${rootFolderPath}/packages/live-share-react`,
stdio: "inherit",
});

installProcess.on("close", (code) => {
if (code == 0) {
resolve();
} else {
reject(code);
}
});
})
});
}

function build() {
const buildProcess = childProcess.spawn("npm", ["run", "build:packages"], {
shell: true,
cwd: rootFolderPath,
stdio: "inherit",
});

const buildProcess = childProcess.spawn(
"npm",
["run", "build:packages"],
{
shell: true,
cwd: rootFolderPath,
stdio: "inherit",
}
);

buildProcess.on("close", (code) => {
if (code === 0) {
fs.writeFileSync(
Expand All @@ -109,4 +123,4 @@ async function ensurePackagesBuilt() {
return undefined;
}
}
}
}
24 changes: 12 additions & 12 deletions internal/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@
"tsc": "tsc"
},
"dependencies": {
"@fluid-experimental/attributor": "^2.0.0-rc.1",
"@fluid-experimental/sequence-deprecated": "^2.0.0-rc.1",
"@fluidframework/agent-scheduler": "^2.0.0-rc.1",
"@fluid-experimental/attributor": "^2.0.0-rc.2.0.0",
"@fluid-experimental/sequence-deprecated": "^2.0.0-rc.2.0.0",
"@fluidframework/agent-scheduler": "^2.0.0-rc.2.0.0",
"@fluidframework/aqueduct": "^2.0.0-rc.1.0.3",
"@fluidframework/cell": "^2.0.0-rc.1",
"@fluidframework/cell": "^2.0.0-rc.2.0.0",
"@fluidframework/container-loader": "^2.0.0-rc.1.0.3",
"@fluidframework/container-runtime": "^2.0.0-rc.1.0.4",
"@fluidframework/core-interfaces": "^2.0.0-rc.1",
"@fluidframework/core-utils": "^2.0.0-rc.1",
"@fluidframework/counter": "^2.0.0-rc.1",
"@fluidframework/core-interfaces": "^2.0.0-rc.2.0.0",
"@fluidframework/core-utils": "^2.0.0-rc.2.0.0",
"@fluidframework/counter": "^2.0.0-rc.2.0.0",
"@fluidframework/datastore-definitions": "^2.0.0-rc.1.0.4",
"@fluidframework/driver-definitions": "^2.0.0-rc.1",
"@fluidframework/local-driver": "^2.0.0-rc.1",
"@fluidframework/driver-definitions": "^2.0.0-rc.2.0.0",
"@fluidframework/local-driver": "^2.0.0-rc.2.0.0",
"@fluidframework/map": "^2.0.0-rc.1.0.4",
"@fluidframework/matrix": "^2.0.0-rc.1",
"@fluidframework/ordered-collection": "^2.0.0-rc.1",
"@fluidframework/matrix": "^2.0.0-rc.2.0.0",
"@fluidframework/ordered-collection": "^2.0.0-rc.2.0.0",
"@fluidframework/register-collection": "^2.0.0-rc.1.0.4",
"@fluidframework/runtime-definitions": "^2.0.0-rc.1.0.4",
"@fluidframework/sequence": "^2.0.0-rc.1.0.4",
"@fluidframework/server-local-server": "^3.1.0-237980",
"@fluidframework/telemetry-utils": "^2.0.0-rc.1.0.4",
"@fluidframework/test-driver-definitions": "^2.0.0-rc.1",
"@fluidframework/test-driver-definitions": "^2.0.0-rc.2.0.0",
"@fluidframework/test-utils": "^2.0.0-rc.1.0.3"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions internal/test-utils/src/describeCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ function createCompatSuite(

before(async function () {
try {
provider =
await getVersionedTestObjectProviderFromApis(apis);
provider = await getVersionedTestObjectProviderFromApis(
apis
);
} catch (error) {
const logger = createChildLogger({
logger: getTestLogger?.(),
Expand Down
Loading