Skip to content

Commit

Permalink
Copy from local features folder
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Jul 6, 2022
1 parent 1887308 commit 30213a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
19 changes: 18 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"type": "node",
"request": "launch",
"name": "Launch cli - up",
"name": "Launch CLI - up",
"program": "${workspaceFolder}/src/spec-node/devContainersSpecCLI.ts",
"cwd": "${workspaceFolder}",
"args": [
Expand All @@ -18,6 +18,23 @@
"debug",
],
"console": "integratedTerminal",
},
{
"type": "node",
"request": "launch",
"name": "Launch Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"cwd": "${workspaceFolder}",
"args": [
"-r",
"ts-node/register",
"--exit",
"src/test/*.test.ts"
],
"env": {
"TS_NODE_PROJECT": "src/test/tsconfig.json"
},
"console": "integratedTerminal",
}
]
}
11 changes: 6 additions & 5 deletions src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function updateFromOldProperties<T extends { features: (Feature & { extensions?:

// Generate a base featuresConfig object with the set of locally-cached features,
// as well as downloading and merging in remote feature definitions.
export async function generateFeaturesConfig(params: { extensionPath: string; cwd: string; output: Log; env: NodeJS.ProcessEnv }, dstFolder: string, config: DevContainerConfig, getLocalFolder: (d: string) => string) {
export async function generateFeaturesConfig(params: { extensionPath: string; cwd: string; output: Log; env: NodeJS.ProcessEnv }, dstFolder: string, config: DevContainerConfig, getLocalFeaturesFolder: (d: string) => string) {
const { output } = params;

const userFeatures = featuresToArray(config);
Expand All @@ -385,7 +385,8 @@ export async function generateFeaturesConfig(params: { extensionPath: string; cw

// load local cache of features;
// TODO: Update so that cached features are always version 2
let locallyCachedFeatureSet = await loadFeaturesJsonFromDisk(getLocalFolder(params.extensionPath), output); // TODO: Pass dist folder instead to also work with the devcontainer.json support package.
const localFeaturesFolder = getLocalFeaturesFolder(params.extensionPath);
const locallyCachedFeatureSet = await loadFeaturesJsonFromDisk(localFeaturesFolder, output); // TODO: Pass dist folder instead to also work with the devcontainer.json support package.
if (!locallyCachedFeatureSet) {
output.write('Failed to load locally cached features', LogLevel.Error);
return undefined;
Expand All @@ -397,7 +398,7 @@ export async function generateFeaturesConfig(params: { extensionPath: string; cw

// Fetch features and get version information
output.write('--- Fetching User Features ----', LogLevel.Trace);
await fetchFeatures(params, featuresConfig, locallyCachedFeatureSet, dstFolder);
await fetchFeatures(params, featuresConfig, locallyCachedFeatureSet, dstFolder, localFeaturesFolder);

const ordererdFeatures = computeFeatureInstallationOrder(config, featuresConfig.featureSets);

Expand Down Expand Up @@ -625,7 +626,7 @@ export function parseFeatureIdentifier(output: Log, userFeature: DevContainerFea
}
}

async function fetchFeatures(params: { extensionPath: string; cwd: string; output: Log; env: NodeJS.ProcessEnv }, featuresConfig: FeaturesConfig, localFeatures: FeatureSet, dstFolder: string) {
async function fetchFeatures(params: { extensionPath: string; cwd: string; output: Log; env: NodeJS.ProcessEnv }, featuresConfig: FeaturesConfig, localFeatures: FeatureSet, dstFolder: string, localFeaturesFolder: string) {
for (const featureSet of featuresConfig.featureSets) {
try {
if (!featureSet || !featureSet.features || !featureSet.sourceInformation)
Expand All @@ -652,7 +653,7 @@ async function fetchFeatures(params: { extensionPath: string; cwd: string; outpu
if (sourceInfoType === 'local-cache') {
// create copy of the local features to set the environment variables for them.
await mkdirpLocal(featCachePath);
await cpDirectoryLocal(path.join(dstFolder, 'local-cache'), featCachePath);
await cpDirectoryLocal(localFeaturesFolder, featCachePath);

await parseDevContainerFeature(featureSet, feature, featCachePath);

Expand Down

0 comments on commit 30213a1

Please sign in to comment.